Replies: 1 comment 4 replies
-
Supabase functions use Deno's Response interface. We can send back data to match const { data, error } = await something()
if (error) {
return new Response(JSON.stringify({ error: error }), { status: 500 })
} else {
return new Response(JSON.stringify({ data: data }), { status: 200 })
} Or even better, if we know const response = await something()
return new Response(JSON.stringify(response), { status: response.error ? 500 : 200 }) |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When calling an edge function via
supabaseClient.functions.invoke
the response can be destructured to{ data, error }
but I can't find any documentation on how to populate the error prop from the edge function? I'm sending back a Response object as per the documentation, whatever is placed in the body of the response populates thedata
prop on the front end. Is there a way of populating the error prop instead somehow?return new Response(JSON.stringify(error), { status: 500 })
Beta Was this translation helpful? Give feedback.
All reactions