app for refbot stuff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 21 lines 634 B view raw
1async function get(path, params = {}) { 2 const url = new URL('/api' + path, window.location.origin) 3 for (const [k, v] of Object.entries(params)) { 4 if (v != null) url.searchParams.set(k, v) 5 } 6 const res = await fetch(url) 7 if (!res.ok) throw new Error(`api error ${res.status}: ${path}`) 8 return res.json() 9} 10 11async function patch(path, body) { 12 const res = await fetch('/api' + path, { 13 method: 'PATCH', 14 headers: { 'Content-Type': 'application/json' }, 15 body: JSON.stringify(body), 16 }) 17 if (!res.ok) throw new Error(`api error ${res.status}: ${path}`) 18 return res.json() 19} 20 21export const api = { get, patch }