mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Website components. Update chart component.
This commit is contained in:
parent
d81ee3932d
commit
bdcdcd9d13
9 changed files with 165 additions and 43 deletions
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue