1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00
unleash.unleash/packages/unleash-frontend-next/src/data/metrics-api.js

21 lines
391 B
JavaScript
Raw Normal View History

2016-10-27 13:12:26 +02:00
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,
};