mirror of
https://github.com/umami-software/umami.git
synced 2026-02-05 21:27:20 +01:00
Get localized error messages.
This commit is contained in:
parent
baba06c692
commit
fc01ee9f56
32 changed files with 90 additions and 85 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { buildUrl } from '@/lib/url';
|
||||
import { buildPath } from '@/lib/url';
|
||||
|
||||
export interface ErrorResponse {
|
||||
error: {
|
||||
|
|
@ -36,18 +36,17 @@ export async function request(
|
|||
return {
|
||||
ok: res.ok,
|
||||
status: res.status,
|
||||
data: res.ok ? data : undefined,
|
||||
error: res.ok ? undefined : data,
|
||||
data,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function httpGet(path: string, params: object = {}, headers: object = {}) {
|
||||
return request('GET', buildUrl(path, params), undefined, headers);
|
||||
return request('GET', buildPath(path, params), undefined, headers);
|
||||
}
|
||||
|
||||
export async function httpDelete(path: string, params: object = {}, headers: object = {}) {
|
||||
return request('DELETE', buildUrl(path, params), undefined, headers);
|
||||
return request('DELETE', buildPath(path, params), undefined, headers);
|
||||
}
|
||||
|
||||
export async function httpPost(path: string, params: object = {}, headers: object = {}) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ export function getQueryString(params: object = {}): string {
|
|||
return searchParams.toString();
|
||||
}
|
||||
|
||||
export function buildUrl(url: string, params: object = {}): string {
|
||||
export function buildPath(path: string, params: object = {}): string {
|
||||
const queryString = getQueryString(params);
|
||||
return `${url}${queryString && '?' + queryString}`;
|
||||
return queryString ? `${path}?${queryString}` : path;
|
||||
}
|
||||
|
||||
export function safeDecodeURI(s: string | undefined | null): string | undefined | null {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue