mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
19 lines
579 B
TypeScript
19 lines
579 B
TypeScript
import type { RequestInit, Response } from 'node-fetch';
|
|
import nodeFetch from 'node-fetch';
|
|
|
|
// first arg can be only a string
|
|
// FIXME migrate to RequestInfo later if needed
|
|
export default function fetch(path: string, init?: RequestInit): Promise<Response> {
|
|
const headers = {
|
|
accept: 'application/json',
|
|
authorization: `Bearer ${ process.env.API_AUTHORIZATION_TOKEN }`,
|
|
'content-type': 'application/json',
|
|
};
|
|
const url = `https://${ process.env.API_HOST }${ process.env.API_BASE_PATH }${ path }`;
|
|
|
|
return nodeFetch(url, {
|
|
headers,
|
|
...init,
|
|
});
|
|
}
|