const request = (resource: string, data: any) => fetch(`/api/${resource}.shs`, { method: 'POST', body: new URLSearchParams(data).toString(), }).then((res) => res.json()); document.addEventListener('load', () => { request('packages', {}) .then((res) => { console.log(res); }); });