RLS is disabled. Role is anon. Seems like that the necessity right? This is my code using nextjs. I made it works previously, but not sure why it doesn't work now.
const fetchSupabaseUser = async (firebaseUser: FirebaseUser | null) => {
if (!firebaseUser) return;
const { data, error, status } = await supabase
.from('users')
.select('*')
.eq('google_id', firebaseUser.uid)
.single();
console.log(error, status);
if (error && status !== 406) {
console.error("Supabase error:", error);
throw error
}
// if (error) console.error("Supabase error:", error);
if (error && Object.keys(error).length !== 0) {
if (error instanceof Error) {
console.error('Error fetching Supabase user:', error.message);
// } else {
// console.error('An unknown error occurred while fetching Supabase user:', error);
}
return;
}
setUser(data);
console.log('Supabase user set:', data);
};
In the Chrome console, I see this:
fetch.ts:15 GET =*&google_id=eq.mbRwFh8AgLZuSaXCscIIkJNFTBz1 406 (Not Acceptable)
Printing the error:
{
code: 'PGRST116',
details: 'The result contains 0 rows',
hint: null,
message: 'JSON object requested, multiple (or no) rows returned'
}
RLS is disabled. Role is anon. Seems like that the necessity right? This is my code using nextjs. I made it works previously, but not sure why it doesn't work now.
const fetchSupabaseUser = async (firebaseUser: FirebaseUser | null) => {
if (!firebaseUser) return;
const { data, error, status } = await supabase
.from('users')
.select('*')
.eq('google_id', firebaseUser.uid)
.single();
console.log(error, status);
if (error && status !== 406) {
console.error("Supabase error:", error);
throw error
}
// if (error) console.error("Supabase error:", error);
if (error && Object.keys(error).length !== 0) {
if (error instanceof Error) {
console.error('Error fetching Supabase user:', error.message);
// } else {
// console.error('An unknown error occurred while fetching Supabase user:', error);
}
return;
}
setUser(data);
console.log('Supabase user set:', data);
};
In the Chrome console, I see this:
fetch.ts:15 GET https://mkibhcvvghfyxutpsaqe.supabase.co/rest/v1/users?select=*&google_id=eq.mbRwFh8AgLZuSaXCscIIkJNFTBz1 406 (Not Acceptable)
Printing the error:
Share Improve this question edited Mar 3 at 6:56 marc_s 757k184 gold badges1.4k silver badges1.5k bronze badges asked Mar 3 at 1:54 swdevswdev 5,1778 gold badges67 silver badges110 bronze badges 1{
code: 'PGRST116',
details: 'The result contains 0 rows',
hint: null,
message: 'JSON object requested, multiple (or no) rows returned'
}
- 1 Whats the full error? Please include that in your post. – ewokx Commented Mar 3 at 1:57
1 Answer
Reset to default 1Sorry, fixed it. single() will return error if empty (but the error code really misguided). so using maybeSingle() solved this