(
path: string,
{ headers, ...options }: RequestInit = {}
)
| 1 | import nodeFetch, { type RequestInit } from '../../src/util/fetch'; |
| 2 | |
| 3 | export const apiFetch = ( |
| 4 | path: string, |
| 5 | { headers, ...options }: RequestInit = {} |
| 6 | ) => { |
| 7 | const url = new URL(path, 'https://api.vercel.com'); |
| 8 | if (process.env.VERCEL_TEAM_ID) { |
| 9 | url.searchParams.set('teamId', process.env.VERCEL_TEAM_ID); |
| 10 | } |
| 11 | return nodeFetch(url, { |
| 12 | headers: { |
| 13 | Authorization: `Bearer ${process.env.VERCEL_TOKEN}`, |
| 14 | ...(headers || {}), |
| 15 | }, |
| 16 | ...options, |
| 17 | }); |
| 18 | }; |