Skip to content

Commit

Permalink
fix(filters): fetch API isn't always an instance of Response
Browse files Browse the repository at this point in the history
- same as previous PR #744, this one was found after
- the output of the Fetch API Promise isn't always an `instanceof Response`, the better way of validating the Fetch resolved output is to check its status to be between 200-300 and also make sure that it has the `.json()` type to be a function
  • Loading branch information
ghiscoding committed Aug 14, 2022
1 parent 9b09e4a commit 974a2d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/common/src/filters/filterUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function renderCollectionOptionsAsync(collectionAsync: Promise<any

if (Array.isArray(response)) {
awaitedCollection = response; // from Promise
} else if (response instanceof Response && typeof response['json'] === 'function') {
} else if (response?.status >= 200 && response.status < 300 && typeof response.json === 'function') {
awaitedCollection = await response['json'](); // from Fetch
} else if (response && response['content']) {
awaitedCollection = response['content']; // from http-client
Expand Down

0 comments on commit 974a2d6

Please sign in to comment.