nomilo/public/scripts/api.js

23 lines
310 B
JavaScript
Raw Normal View History

2022-04-29 02:29:10 +00:00
const baseUrl = '/api/v1';
function apiGet(url) {
return fetch(`${baseUrl}/${url}`)
.then(res => {
if (!res.ok) {
// do something here
throw new Error('Not ok');
}
return res.json();
})
}
function getRecords(zone) {
return apiGet(`zones/${zone}/records`)
}
export {
getRecords,
};