regex
02/05/2022, 8:40 PMexport default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const user = await supabase.auth.user();
const { data, error, status } = await supabase
.from("profiles")
.select(`username, country, avatar_url`)
.eq("id", user?.id)
.single();
if (error) return res.status(status).json({ error: error.message });
return res.status(200).json({ user: data });
}
However, I am getting an error response error: "invalid input syntax for type uuid: \"undefined\""
Can't I reach logged in user's id inside the API folder?garyaustin
02/05/2022, 9:12 PMuser()
will return the user data, if there is a logged in user.
*
* For server-side management, you can get a user through auth.api.getUserByCookie()
*/
user(): User | null {
return this.currentUser
}garyaustin
02/05/2022, 9:13 PMregex
02/05/2022, 10:02 PMgaryaustin
02/05/2022, 10:21 PMregex
02/05/2022, 10:53 PMgaryaustin
02/05/2022, 11:03 PM