mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
21 lines
391 B
JavaScript
21 lines
391 B
JavaScript
|
const URI = '/metrics';
|
||
|
|
||
|
function throwIfNotSuccess (response) {
|
||
|
if (!response.ok) {
|
||
|
let error = new Error('API call failed');
|
||
|
error.status = response.status;
|
||
|
throw error;
|
||
|
}
|
||
|
return response;
|
||
|
}
|
||
|
|
||
|
function fetchAll () {
|
||
|
return fetch(URI)
|
||
|
.then(throwIfNotSuccess)
|
||
|
.then(response => response.json());
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
fetchAll,
|
||
|
};
|