mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Imported libraries, removed next-basics.
This commit is contained in:
parent
31266cb1ac
commit
113022ed17
44 changed files with 361 additions and 180 deletions
31
src/lib/fetch.ts
Normal file
31
src/lib/fetch.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { buildUrl } from 'lib/url';
|
||||
|
||||
export async function request(method: string, url: string, body?: string, headers: object = {}) {
|
||||
const res = await fetch(url, {
|
||||
method,
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
...headers,
|
||||
},
|
||||
body,
|
||||
});
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export function httpGet(url: string, params: object = {}, headers: object = {}) {
|
||||
return request('GET', buildUrl(url, params), undefined, headers);
|
||||
}
|
||||
|
||||
export function httpDelete(url: string, params: object = {}, headers: object = {}) {
|
||||
return request('DELETE', buildUrl(url, params), undefined, headers);
|
||||
}
|
||||
|
||||
export function httpPost(url: string, params: object = {}, headers: object = {}) {
|
||||
return request('POST', url, JSON.stringify(params), headers);
|
||||
}
|
||||
|
||||
export function httpPut(url: string, params: object = {}, headers: object = {}) {
|
||||
return request('PUT', url, JSON.stringify(params), headers);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue