compare two code blocks · line & word level · side-by-side or unified
| 1 | function fetchUser(id: string): Promise<User> { | | |
| 2 | const url = `/api/users/${id}`; | | |
| 3 | const res = await fetch(url); | | |
| 4 | if (!res.ok) throw new Error('not found'); | | |
| 5 | return res.json(); | 1 | async function fetchUser(id: string): Promise<User | null> { |
| 2 | const url = `/api/v2/users/${id}`; | |
| 3 | const res = await fetch(url, { cache: 'no-store' }); | |
| 4 | if (!res.ok) return null; | |
| 5 | const data = await res.json(); | |
| 6 | return data as User; | |
| 6 | } | 7 | } |