-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
blockedMerging this pull request is blocked until another issue is resolvedMerging this pull request is blocked until another issue is resolvedrefactoringCode refactoring without functional changesCode refactoring without functional changestech deptRemoves some technical debtRemoves some technical debt
Milestone
Description
Use typed responses instead of generic Response
type from fetch
.
Currently, every component parses the body by itself (including error handling).
With this change applied, calling api endpoints should be much more streamlined and simplified.
e.g. from https://eckertalex.dev/blog/typescript-fetch-wrapper
async function request<T>(path: string, config: RequestInit): Promise<T> {
const response = await fetch(new Request(path, config))
if (!response.ok) {
// TODO: use Api.Helper here instead generic Error
throw new Error({ name: response.status, message: response.statusText })
}
// may error if there is no body, return empty
return response.json().catch(() => ({}))
}
Metadata
Metadata
Assignees
Labels
blockedMerging this pull request is blocked until another issue is resolvedMerging this pull request is blocked until another issue is resolvedrefactoringCode refactoring without functional changesCode refactoring without functional changestech deptRemoves some technical debtRemoves some technical debt
Type
Projects
Status
No status