Chris_Acrobat
04/03/2022, 5:48 PMJavaScript
console.log((await req.text()).length)
And from curl I get a valid number, but from fetch I get 0. Can anyone see/say what I am doing wrong in my fetch request?
JavaScript
fetch(new Request('https://_exeample_.functions.supabase.co/login'), {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': 'Bearer anon-key-from-https://app.supabase.io/project/_exeample_'
}),
body: JSON.stringify({
a: "A",
b: "B"
})
})
garyaustin
04/03/2022, 5:52 PMgaryaustin
04/03/2022, 5:53 PMChris_Acrobat
04/03/2022, 5:54 PMRequest method: OPTIONS
Status code: 200
Referrer policy: strict-origin-when-cross-origin
garyaustin
04/03/2022, 5:55 PMgaryaustin
04/03/2022, 5:55 PMgaryaustin
04/03/2022, 5:58 PMexport async function SBcallFunction() {
const body = JSON.stringify({doc:"abc",fileName:"myfile",name:"gary"})
console.log('email')
const response = await fetch(`https://supaurl.functions.supabase.co/get-pdf`, {
method: 'POST',
headers: {
"Content-Type": "application/json",
'Authorization':`Bearer authkey`
},
body:body,
})
Chris_Acrobat
04/03/2022, 6:02 PMgaryaustin
04/03/2022, 6:03 PMChris_Acrobat
04/03/2022, 6:03 PMsplit out the OPTION and POST
?Chris_Acrobat
04/03/2022, 6:05 PMChris_Acrobat
04/03/2022, 6:13 PMapikey
a placeholder for the anon key?garyaustin
04/03/2022, 6:14 PMChris_Acrobat
04/03/2022, 6:14 PMgaryaustin
04/03/2022, 6:17 PMChris_Acrobat
04/03/2022, 6:24 PMChris_Acrobat
04/03/2022, 7:51 PMChris_Acrobat
04/03/2022, 7:51 PMgaryaustin
04/03/2022, 7:51 PMChris_Acrobat
04/03/2022, 7:59 PMChris_Acrobat
04/03/2022, 8:05 PMgaryaustin
04/03/2022, 8:39 PMgaryaustin
04/04/2022, 3:40 PMChris_Acrobat
04/04/2022, 3:51 PM