@nxtedition/nxt-undici 6.4.4 → 6.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +4 -0
- package/lib/interceptor/lookup.js +2 -0
- package/lib/request.js +8 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -96,6 +96,10 @@ function wrapDispatch(dispatcher) {
|
|
|
96
96
|
interceptors.responseError(),
|
|
97
97
|
interceptors.query(),
|
|
98
98
|
(dispatch) => (opts, handler) => {
|
|
99
|
+
if (!opts.origin) {
|
|
100
|
+
throw new TypeError('opts.origin is required')
|
|
101
|
+
}
|
|
102
|
+
|
|
99
103
|
const headers = parseHeaders(opts.headers)
|
|
100
104
|
|
|
101
105
|
// TODO (fix): Move to interceptor?
|
|
@@ -8,6 +8,8 @@ export default () => (dispatch) => (opts, handler) => {
|
|
|
8
8
|
const callback = (err, origin) => {
|
|
9
9
|
if (err) {
|
|
10
10
|
handler.onError(err)
|
|
11
|
+
} else if (!origin) {
|
|
12
|
+
handler.onError(new Error('invalid origin: ' + origin))
|
|
11
13
|
} else {
|
|
12
14
|
dispatch({ ...opts, origin }, handler)
|
|
13
15
|
}
|
package/lib/request.js
CHANGED
|
@@ -183,18 +183,12 @@ export function request(dispatch, url, opts) {
|
|
|
183
183
|
path = url.search ? `${url.pathname}${url.search}` : url.pathname
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
body: isStream(opts.body) && opts.body.readableEnded ? null : opts.body,
|
|
195
|
-
},
|
|
196
|
-
resolve,
|
|
197
|
-
),
|
|
198
|
-
),
|
|
199
|
-
)
|
|
186
|
+
opts = {
|
|
187
|
+
...opts,
|
|
188
|
+
origin,
|
|
189
|
+
path,
|
|
190
|
+
body: isStream(opts?.body) && opts.body.readableEnded ? null : opts?.body,
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return new Promise((resolve) => dispatch(opts, new RequestHandler(opts, resolve)))
|
|
200
194
|
}
|