-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Description
The current implementation of the fetch function on Stac api has it returning the response only if it succeeded (lines 121-125):
stac-react/src/stac-api/index.ts
Lines 109 to 127 in a4b4881
| fetch(url: string, options: Partial<FetchOptions> = {}): Promise<Response> { | |
| const { method = 'GET', payload, headers = {} } = options; | |
| return fetch(url, { | |
| method, | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| ...headers, | |
| ...this.options?.headers, | |
| }, | |
| body: payload ? JSON.stringify(payload) : undefined, | |
| }).then(async (response) => { | |
| if (response.ok) { | |
| return response; | |
| } | |
| return this.handleError(response); | |
| }); | |
| } |
This means that all the error validation happening in the handleStacResponse utility will never be used as this function won't be called with a failing response.
I'd suggest that the handleError method be removed from the Stac api class and the response returned directly.
sandrahoang686
Metadata
Metadata
Assignees
Labels
No labels