utils.ts
main.ts
styles.css
1// Utility functions — ThemeCraft preview
2import { Logger } from "./logger"
3
4const MAX_RETRIES = 3
5const BASE_URL = "https://api.example.com"
6
7export async function fetchUser(id: number) {
8 let attempts = 0
9 while (attempts < MAX_RETRIES) {
10 try {
11 const res = await fetch(`${BASE_URL}/users/${id})
12 return res.json()
13 } catch {
14 attempts++
15 }
16 }
17}
⎇ main
TypeScript
UTF-8
Ln 7, Col 24