(userId: string | number)
| 19 | * Fetch all API tokens for a given user |
| 20 | */ |
| 21 | export async function getUserTokens(userId: string | number): Promise<UserToken[]> { |
| 22 | try { |
| 23 | const response = await fetchWithErrorHandling( |
| 24 | `${API_ENDPOINTS.user.tokens}?user_id=${userId}` |
| 25 | ); |
| 26 | const result: TokenListResponse = await response.json(); |
| 27 | return result.data ?? []; |
| 28 | } catch (error) { |
| 29 | if (error instanceof ApiError) { |
| 30 | throw error; |
| 31 | } |
| 32 | throw new ApiError(500, "Failed to fetch user tokens"); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Delete an API token by its ID |
no test coverage detected