Skip to content

Commit

Permalink
Backport sindresorhus#1543: Initialize globalResponse in case of igno…
Browse files Browse the repository at this point in the history
…red HTTPError
  • Loading branch information
nextlevelbeard committed Mar 25, 2022
1 parent 0da732f commit 99100b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/as-promise/index.ts
Expand Up @@ -124,13 +124,13 @@ export default function asPromise<T>(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);
});

Expand Down

0 comments on commit 99100b6

Please sign in to comment.