Skip to content

Commit ff918fb

Browse files
authoredNov 30, 2020
Fix promise shortcuts in case of error status code (#1543)
1 parent 1107cc6 commit ff918fb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎source/as-promise/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ export default function asPromise<T>(normalizedOptions: NormalizedOptions): Canc
124124
return;
125125
}
126126

127+
globalResponse = response;
128+
127129
if (!isResponseOk(response)) {
128130
request._beforeError(new HTTPError(response));
129131
return;
130132
}
131133

132-
globalResponse = response;
133-
134134
resolve(request.options.resolveBodyOnly ? response.body as T : response as unknown as T);
135135
});
136136

‎test/promise.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test('promise.json() can be called before a file stream body is open', withServe
8080
await Promise.all(checks);
8181
});
8282

83-
test.failing('promise.json() does not fail when server returns an error', withServer, async (t, server, got) => {
83+
test('promise.json() does not fail when server returns an error', withServer, async (t, server, got) => {
8484
server.get('/', (_request, response) => {
8585
response.statusCode = 400;
8686
response.end('{}');

0 commit comments

Comments
 (0)
Please sign in to comment.