Skip to content

Commit 54d78b9

Browse files
committed
fix: pass request-compatible API to request.hook(request, options)
1 parent 8f176a5 commit 54d78b9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/with-defaults.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,18 @@ export default function withDefaults(
2525
return fetchWrapper(endpoint.parse(endpointOptions));
2626
}
2727

28-
return endpointOptions.request.hook((options: Defaults) => {
29-
return fetchWrapper(endpoint.parse(options));
30-
}, endpointOptions);
28+
const request = (route: Route | Endpoint, parameters?: Parameters) => {
29+
return fetchWrapper(
30+
endpoint.parse(endpoint.merge(<Route>route, parameters))
31+
);
32+
};
33+
34+
Object.assign(request, {
35+
endpoint,
36+
defaults: withDefaults.bind(null, endpoint)
37+
});
38+
39+
return endpointOptions.request.hook(request, endpointOptions);
3140
};
3241

3342
return Object.assign(newApi, {

0 commit comments

Comments
 (0)