28 lines
749 B
JavaScript
28 lines
749 B
JavaScript
const router = require('express').Router();
|
|
const { getSupabaseClient } = require('../supabaseClient');
|
|
|
|
// POST /profile
|
|
router.get('/profile', async (req, res) => {
|
|
const { user_id } = req.body;
|
|
const supabase = getSupabaseClient();
|
|
const { data, error } = await supabase.from('user_profiles').select(`
|
|
id,
|
|
full_name,
|
|
avatar_url,
|
|
updated_at,
|
|
users(phone)
|
|
`).eq('id', user_id);
|
|
console.log('@@@@@@@@@@@@@@@@@@@@@@@@');
|
|
console.log(data);
|
|
if (error) return res.status(400).json({ error: error.message });
|
|
res.json({
|
|
id: data.id,
|
|
username: data.full_name,
|
|
avatar_url: data.avatar_url,
|
|
phone: data.users.phone,
|
|
apartment: '9',
|
|
updated_at: data.updated_at
|
|
});
|
|
});
|
|
|
|
module.exports = router;
|