---
title: Code Drawer
slug: eng-1268-map-marker/hZfCe0BK5yyloVLp5iDKo
icon: {"faIcon":"fa-solid fa-draw-polygon"}
docTags: 
createdAt: 2026-07-17T11:28:10.000Z
---

::::CodeDrawer{title="Get User Profile (TypeScript)" isResponseExpanded="true" autoGeneratedAnchorSlug="get-user-profile-typescript" legacyHash="mPIpN5ziPxosjDbEEcegp"}
:::CodeblockTabsExamples
```typescript
type UserProfile = {
  id: string;
  email: string;
  fullName: string;
  plan: "free" | "pro" | "enterprise";
};

export async function getUserProfile(userId: string): Promise<UserProfile> {
  const response = await fetch(`https://api.example.com/v1/users/${userId}`, {
    method: "GET",
    headers: {
      Accept: "application/json",
      Authorization: `Bearer ${process.env.API_TOKEN ?? ""}`
    }
  });

  if (!response.ok) {
    throw new Error(`Failed to fetch profile (${response.status})`);
  }

  return (await response.json()) as UserProfile;
}
```
:::

:::CodeblockTabsResponses
```typescript
{
  "id": "usr_8f3b91",
  "email": "ava@company.com",
  "fullName": "Ava Williams",
  "plan": "pro"
}
```
:::
::::
