silentworks
11/10/2021, 10:34 AMuser
11/10/2021, 11:30 AMuser
11/10/2021, 11:31 AMrc9999999
11/10/2021, 11:51 AMrc9999999
11/10/2021, 11:51 AMrc9999999
11/10/2021, 11:53 AMconst { user_id } = router.query;
useEffect(() => {
fetchIt();
}, []);
async function fetchIt() {
try {
setLoading(true);
const { data, error } = await supabase
.from("posts")
.select("title, created_by")
.match({ created_by: user_id });
setPosts(data);
console.log({ posts: data });
if (error) throw error;
} catch (error) {
console.log(error);
} finally {
setLoading(false);
}
}
magicbyt3
11/10/2021, 12:17 PMjs
const { data, error, status } = await supabase
.from('rooms')
.select('*, owner:profiles(nickname), opponent:profiles(nickname)');
hint "By following the 'details' key, disambiguate the request by changing the url to /origin?select=relationship(*) or /origin?select=target!relationship(*)"
message "More than one relationship was found for rooms and profiles"
details [ {…}, {…} ]
0 Object { origin: "public.rooms", relationship: "rooms_opponent_fkey[opponent][id]", cardinality: "m2o", … }
origin "public.rooms"
relationship "rooms_opponent_fkey[opponent][id]"
cardinality "m2o"
target "public.profiles"
1 Object { origin: "public.rooms", relationship: "fk_profiles_rooms_opp[opponent][id]", cardinality: "m2o", … }
origin "public.rooms"
relationship "fk_profiles_rooms_opp[opponent][id]"
cardinality "m2o"
target "public.profiles"
How can I disambiguate these?silentworks
11/10/2021, 12:56 PMMrPoule
11/10/2021, 1:46 PMsupabase.auth.signIn
on the client side and I'm doing this in an API endpoint receiving the user email and password. And if authentication is successful I would like to set the authentication cookie in the response in order to allow authentication of future requests server side (based on setAuth).
I currently have found a way to do all this, but my sign-in endpoint feels very clunky (calling setAuthCookie with a modified request body). Here is what I have, do you see anyway to do the same differently or is this the best that can be done?
javascript
export const post = async (request, response) => {
const { session, error } = await supabase.auth.signIn({
email: request.body.get('email'),
password: request.body.get('password'),
});
if (!error) {
request.body = {
event: 'SIGNED_IN',
session: session,
};
supabase.auth.api.setAuthCookie(request, response);
response.redirect(302, '/')
return response;
}
return {
headers: { Location: `/signin?error=${encodeURIComponent(error.message)}` },
status: 302,
};
};
Thanks in advance, I just love supabase! jon.m
11/10/2021, 2:47 PMsilentworks
11/10/2021, 2:48 PMjon.m
11/10/2021, 3:53 PMYelloJello
11/10/2021, 4:17 PMfrancisco.ew
11/10/2021, 5:16 PMsilentworks
11/10/2021, 5:37 PMsilentworks
11/10/2021, 5:39 PMSteve
11/10/2021, 6:29 PMKevin21
11/10/2021, 8:15 PMjon
11/10/2021, 8:23 PMYelloJello
11/12/2021, 9:36 AMMrPoule
11/12/2021, 11:50 AMaskrodney
11/12/2021, 2:13 PMaskrodney
11/12/2021, 2:13 PMaskrodney
11/12/2021, 2:14 PMaskrodney
11/12/2021, 2:14 PMaskrodney
11/12/2021, 2:15 PMaskrodney
11/12/2021, 2:15 PMaskrodney
11/12/2021, 2:16 PMaskrodney
11/12/2021, 2:16 PMaskrodney
11/12/2021, 2:16 PM