call.ts
1 const BASE_URL = "https://services.wallper.app"; 2 const USER_AGENT = "Wallper/1 CFNetwork/3860.300.31 Darwin/25.2.0"; 3 4 export const json = async <T, B = undefined>( 5 method: string, 6 path: string, 7 body?: B, 8 ): Promise<T> => { 9 const headers = new Headers(); 10 headers.set("User-Agent", USER_AGENT); 11 12 if (body) { 13 headers.set("Content-Type", "application/json"); 14 } 15 16 const response = await fetch(BASE_URL + path, { 17 method, 18 headers, 19 body: body && JSON.stringify(body), 20 }); 21 22 const json = await response.json(); 23 return json as T; 24 };