-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pick nodes consistently in "npm run dev", and query fixes #394
Changes from all commits
458e513
8f20637
db79f85
e03d95c
eaa223d
39b8e51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,16 +26,13 @@ export const generatePostReq = (stringBody: string): RequestInit => { | |
}; | ||
|
||
export const returnResponse = async ( | ||
res: Response, | ||
resFn: () => Promise<Response>, | ||
errorMsg: string, | ||
ignoreStatuses: number[] = [] | ||
) => { | ||
const res = await resFn(); | ||
if (!res.ok && !ignoreStatuses.includes(res.status)) { | ||
throw new Error(errorMsg); | ||
} | ||
try { | ||
return (await res.json()).result; | ||
} catch { | ||
return {}; | ||
} | ||
return (await res.json()).result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original goal of this try catch was to quietly handle cases where the value returned is not a valid JSON. Note that with this change we assume the response will always be a valid JSON. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very helpful to have that - I couldn't work that out from the code alone, as it seemed to be deliberately translating errors in a success payload. I thought that was the intent of the code. A note that I didn't see a change / comments / intent described in the changes under #399, so if you have more updates to make a single approach to the different types of errors coming back to the UI true, that would be great. The "error" categories include:
|
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was the key fix - that
resFn
wasn't being await'ed in the previous param structure ofreturnResponse