-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
Problem
Was running into an issue when our backend openapi spec'd response for an endpoint was a 204 No Content success status. The client side code was throwing an error so we couldn't trigger the onSuccess function through the react query component. The error was the following thrown in the autogenerated fetcher script:
message: "Network error (Unexpected end of JSON input)"name: "unknown"stack: SyntaxError: Unexpected end of JSON input
Workaround
Check the response status in the fetcher AFTER the fetch, e.g.
if (response.status === 204) {
return {} as TData;
}
Could also return null or something else you want.
benmeyer50
Metadata
Metadata
Assignees
Labels
No labels