26 lines
775 B
JavaScript
26 lines
775 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('users').select(`
|
|
id,
|
|
phone,
|
|
user_profiles(full_name,avatar_url,updated_at)
|
|
`).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.user_profiles.full_name,
|
|
avatar_url: data.user_profiles.avatar_url,
|
|
phone: data.phone,
|
|
apartment: '9',
|
|
updated_at: data.user_profiles.updated_at
|
|
});
|
|
});
|
|
|
|
module.exports = router;
|