Skip to content

Commit f57f14a

Browse files
committed
fix: pass parsed options into request
this should be a refactor but @ocotkit/rest uses these internals
1 parent 555b831 commit f57f14a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/request.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const mockable = require('./fetch')
88
const getBuffer = require('./get-buffer-response')
99
const HttpError = require('./http-error')
1010

11-
function request (endpoint, route, options) {
12-
const requestOptions = endpoint(route, options)
13-
11+
function request (requestOptions) {
1412
if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
1513
requestOptions.body = JSON.stringify(requestOptions.body)
1614
}

lib/with-defaults.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const request = require('./request')
44

55
function withDefaults (oldEndpoint, newDefaults) {
66
const endpoint = oldEndpoint.defaults(newDefaults)
7-
const newApi = request.bind(null, endpoint)
7+
const newApi = function (route, options) {
8+
return request(endpoint(route, options))
9+
}
10+
811
newApi.endpoint = endpoint
912
newApi.defaults = withDefaults.bind(null, endpoint)
1013
return newApi

0 commit comments

Comments
 (0)