const headersInit = { Accept: 'application/json', 'Content-Type': 'application/json', }; export const get = async (path: RequestInfo) => { const res = await fetch(path, { method: 'GET', }); if (!res.ok) { throw new Error(res.statusText); } return res; }; export const post = async (path: RequestInfo, token?: string, data?: string) => { const res = await fetch(path, { method: 'POST', headers: { ...headersInit, 'x-access-refactor-token': token, }, body: data, }); if (!res.ok) { throw new Error(res.statusText); } return res; }; export const put = async (path: RequestInfo, token?: string, data?: string) => { const res = await fetch(path, { method: 'PUT', headers: { ...headersInit, 'x-access-refactor-token': token, }, body: data, }); if (!res.ok) { throw new Error(res.statusText); } return res; }; export const del = async (path: RequestInfo, token?: string, data?: string) => { const res = await fetch(path, { method: 'DELETE', headers: { ...headersInit, 'x-access-refactor-token': token, }, body: data, }); if (!res.ok) { throw new Error(res.statusText); } return res; };