diff --git a/source/as-promise/index.ts b/source/as-promise/index.ts index efd94703c..4d8d5e041 100644 --- a/source/as-promise/index.ts +++ b/source/as-promise/index.ts @@ -124,13 +124,13 @@ export default function asPromise(normalizedOptions: NormalizedOptions): Canc return; } + globalResponse = response; + if (!isResponseOk(response)) { request._beforeError(new HTTPError(response)); return; } - globalResponse = response; - resolve(request.options.resolveBodyOnly ? response.body as T : response as unknown as T); });