Getting an 204 status code without content using supabase.functions.invoke cause error
When we invoke an supabase function and getting an 204 return with no content then the function crash. While i'm expacting that when resolved to an 204 (no-content see https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/204) it doesn't try to parse the json. Is this an bug or do we need to send something extra with the invoke method to make sure we don't parse the response by default?
Our code looks like this:
await supabase.functions.invoke(
"item_delete",
{
method: "DELETE",
body: { id: itemId }
}
);
1 Reply
Turned out my function returned the Content-Type: "application/json" what cause this issue. Returning the Content-Type: "text/plain" fixed the issue. Now it works when returning an 204 with no content.
Still think the functions-js should return null when getting a 204 status code and not do anything with the body.