Currently, I am calling a supabase edge function using the code snippet below:
async function getData(plan_data){
console.log(plan_data)
console.log(JSON.stringify({plan_data}))
const { data, error } = await supabase.functions.invoke("create-stripe-checkout",
{
body: JSON.stringify({
plan_data
}),
}
)
console.log(data, error)
}
Upon inspecting the edge function, I noticed that the request logged "bodyUsed: false", indicating that the edge function believes no value was passed (even though one was passed to the getData function correctly). I have tried tweaking the syntax without success. Is there something I may be overlooking?
EDIT: The edge function code is as follows:
import { serve } from "https://deno.land/@std/http/server.ts"
serve(async (req) => {
if (req.method === "OPTIONS"){
return new Response (null, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "apikey, X-Client-Info, Authorization, content-type",
}
})
}
console.log(req)
const { planId } = await req.json()
console.log(planId)
return new Response(
JSON.stringify({ planId }),
{ headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "apikey, X-Client-Info, Authorization, content-type",
} },
)
})
https://i.sstatic.net/X5ENx.png
EDIT: I also tested it with supabase's sample code and encountered the same issue.