Tiger Abrodi 🐆
11/23/2021, 3:09 PMletourpowerscombine
11/23/2021, 4:19 PM"FetchError: XMLHttpRequest is not defined"
when making Supabase calls on a Cloudflare Pages deployment.
I also noticed this issue (https://github.com/supabase/supabase-js/issues/154) which seemed relevant. I followed that advice, doing the createClient
with a defined fetch method — but I'm still encountering the error.
Here's the request to Supabase:
javascript
// import supabase from "$lib/db"
import { variables } from '$lib/variables';
import { createClient } from '@supabase/supabase-js'
const supabase = createClient( import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_ANON_KEY, { fetch: customFetch })
export async function post(request) {
const {data, error} = await supabase
.from('support_responses')
.insert({support_info: request.body.get('support_info'), introduction: request.body.get('introduction'), contact: request.body.get('contact'), loaded_location: request.body.get('loaded_address'), searched_location: request.body.get('address')})
if (error) {
return {
status: 500,
body: error
}
}
else {
return {
status: 200,
body: {
data
}
}
}
}
Can someone help me write the customFetch
function that could make this work?
EDIT: Solved, solution in the same GitHub thread. Had to update supabase to 1.28 and use this syntax
const supabase = createClient( import.meta.env.VITE_SUPABASE_URL,
import.meta.env.VITE_SUPABASE_ANON_KEY, { fetch: (...args) => fetch(...args) })
Hal
11/23/2021, 4:29 PMbtelles
11/23/2021, 5:00 PMuser
11/23/2021, 5:28 PMuser
11/23/2021, 5:30 PMAdi
11/23/2021, 6:01 PMHal
11/23/2021, 6:04 PMAdi
11/23/2021, 7:03 PMsilentworks
11/23/2021, 7:26 PMwillm
11/24/2021, 6:29 AMwillm
11/24/2021, 6:30 AManothercoder
11/24/2021, 8:53 AMuser
11/24/2021, 1:18 PMVuNguyen
11/24/2021, 2:24 PMjumpship
11/24/2021, 2:52 PMin()
is workingjumpship
11/24/2021, 2:52 PM.in("field", [1, 2]) // works
jumpship
11/24/2021, 2:52 PMjumpship
11/24/2021, 2:52 PM.in("field", []) // doesn't work
jumpship
11/24/2021, 2:53 PMjumpship
11/24/2021, 2:53 PM.in("field", [*])
or equivalent?jumpship
11/24/2021, 2:55 PMfield
. I'm filtering my table by this field, and so I want to get any values I specify, or if I don't specify any, I want all the resultsjumpship
11/24/2021, 2:55 PM.in("field", [])
to return all results, but instead it returns nonejumpship
11/24/2021, 2:57 PM.in("field", [1, 2, 3, 4, 5]);
but that feels a bit weird(?)garyaustin
11/24/2021, 3:25 PMbtelles
11/24/2021, 4:09 PMjumpship
11/24/2021, 4:16 PMjumpship
11/24/2021, 4:46 PMjumpship
11/24/2021, 4:46 PMasync function fetchCandidates() {
let { data, error, status, count } = await supabase
.from("users")
.select("*")
.eq("role", "developer")
cssIsEmptyArray? '' : .in('css', filters.find(item =>item.skill === 'css').active)
return data
}
jumpship
11/24/2021, 4:47 PM