cURL
curl --request GET \ --url https://harbor-parking.vercel.app/api/profile
{ "profile": { "id": "123e4567-e89b-12d3-a456-426614174000", "email": "john.doe@example.com", "full_name": "John Doe", "apartment_number": "12A", "phone_number": "+1234567890", "is_approved": true, "is_admin": false, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" }, "user": { "id": "123e4567-e89b-12d3-a456-426614174000", "email": "john.doe@example.com", "email_confirmed_at": "2024-01-15T10:30:00Z", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" } }
Retrieve the authenticated user’s profile information and basic user data
Show Profile Object
Show User Object
curl -X GET "https://harbor-parking.vercel.app/api/profile" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -H "Content-Type: application/json"
{ "error": "Authentication required" }
const { profile } = await fetch('/api/profile').then(r => r.json()); if (!profile.is_approved) { // Redirect to pending approval page showPendingApprovalMessage(); } else { // User can access full features redirectToDashboard(); }
const { profile, user } = await fetch('/api/profile').then(r => r.json()); const userInfo = { displayName: profile.full_name || user.email, apartment: profile.apartment_number, isAdmin: profile.is_admin, memberSince: new Date(user.created_at).toLocaleDateString() };
function checkProfileCompleteness(profile) { const missing = []; if (!profile.full_name) missing.push('full_name'); if (!profile.phone_number) missing.push('phone_number'); return { isComplete: missing.length === 0, missingFields: missing, completionPercentage: ((4 - missing.length) / 4) * 100 }; }