mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 22:57:12 +01:00
URL filter functionality.
This commit is contained in:
parent
6bc371352c
commit
4fded49b03
27 changed files with 251 additions and 117 deletions
16
lib/web.js
16
lib/web.js
|
|
@ -1,3 +1,5 @@
|
|||
import { getQueryString } from './url';
|
||||
|
||||
export const apiRequest = (method, url, body) =>
|
||||
fetch(url, {
|
||||
method,
|
||||
|
|
@ -20,19 +22,9 @@ export const apiRequest = (method, url, body) =>
|
|||
return null;
|
||||
});
|
||||
|
||||
const 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;
|
||||
};
|
||||
export const get = (url, params) => apiRequest('get', `${url}${getQueryString(params)}`);
|
||||
|
||||
export const get = (url, params) => apiRequest('get', parseQuery(url, params));
|
||||
|
||||
export const del = (url, params) => apiRequest('delete', parseQuery(url, params));
|
||||
export const del = (url, params) => apiRequest('delete', `${url}${getQueryString(params)}`);
|
||||
|
||||
export const post = (url, params) => apiRequest('post', url, JSON.stringify(params));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue