Skip to content

Error handling in STAC API prevents use of handleStacResponse utility #41

@danielfdsilva

Description

@danielfdsilva

The current implementation of the fetch function on Stac api has it returning the response only if it succeeded (lines 121-125):

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions