22 lines
384 B
JavaScript
22 lines
384 B
JavaScript
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,
|
|
};
|