Website components. Update chart component.
This commit is contained in:
23
lib/web.js
23
lib/web.js
@@ -7,17 +7,20 @@ export const apiRequest = (method, url, body) =>
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
}).then(res => (res.ok ? res.json() : null));
|
||||
}).then(res => {
|
||||
if (res.ok) {
|
||||
return res.json();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
function parseQuery(url, params) {
|
||||
const query =
|
||||
params &&
|
||||
Object.keys(params).reduce((values, key) => {
|
||||
if (params[key] !== undefined) {
|
||||
return values.concat(`${key}=${encodeURIComponent(params[key])}`);
|
||||
}
|
||||
return values;
|
||||
}, []);
|
||||
function parseQuery(url, params = {}) {
|
||||
const query = Object.keys(params).reduce((values, key) => {
|
||||
if (params[key] !== undefined) {
|
||||
return values.concat(`${key}=${encodeURIComponent(params[key])}`);
|
||||
}
|
||||
return values;
|
||||
}, []);
|
||||
return query.length ? `${url}?${query.join('&')}` : url;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user