Website components. Update chart component.

This commit is contained in:
Mike Cao committed 2020-07-28 01:17:45 -07:00
1 parent d81ee3932d
commit bdcdcd9d13
9 files changed
+165 -43

No files matched your search

+13 -10
View File
@@ -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;
}