Retorna os dados do usuário autenticado
cURL
curl --request GET \ --url https://api.example.com/users/me
{ "id": "550e8400-e29b-41d4-a716-446655440000", "email": "[email protected]", "nome": "João Silva", "telefone": "+5511999999999", "cpf": "12345678900", "avatar_url": "https://storage.indiqai.com/avatars/joao.jpg", "referral_code": "JOAO2024", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-06-20T14:15:00Z", "stats": { "total_points": 2500, "total_referrals": 12, "total_rewards_redeemed": 5 } }
curl -X GET https://api.indiqai.com/api/v1/users/me \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
Show Campos de stats
import { useQuery } from '@tanstack/react-query'; import { apiClient } from '@/lib/api-client'; export function useProfile() { return useQuery({ queryKey: ['profile'], queryFn: async () => { const { data } = await apiClient.get('/users/me'); return data; } }); } // No componente function ProfilePage() { const { data: user, isLoading } = useProfile(); if (isLoading) return <Loading />; return ( <div> <h1>{user.nome}</h1> <p>{user.email}</p> </div> ); }
Was this page helpful?