mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Changed fetch response.
This commit is contained in:
parent
7a0575e33a
commit
26463973cb
8 changed files with 36 additions and 13 deletions
|
|
@ -2,16 +2,16 @@ import { useCallback } from 'react';
|
|||
import * as reactQuery from '@tanstack/react-query';
|
||||
import { getClientAuthToken } from '@/lib/client';
|
||||
import { SHARE_TOKEN_HEADER } from '@/lib/constants';
|
||||
import { httpGet, httpPost, httpPut, httpDelete } from '@/lib/fetch';
|
||||
import { httpGet, httpPost, httpPut, httpDelete, FetchResponse } from '@/lib/fetch';
|
||||
import useStore from '@/store/app';
|
||||
|
||||
const selector = (state: { shareToken: { token?: string } }) => state.shareToken;
|
||||
|
||||
async function handleResponse(data: any): Promise<any> {
|
||||
if (data.error) {
|
||||
return Promise.reject(new Error(data.error));
|
||||
async function handleResponse(res: FetchResponse): Promise<any> {
|
||||
if (!res.ok) {
|
||||
return Promise.reject(new Error(res.error));
|
||||
}
|
||||
return Promise.resolve(data);
|
||||
return Promise.resolve(res.data);
|
||||
}
|
||||
|
||||
function handleError(err: Error | string) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export function useCountryNames(locale: string) {
|
|||
const [list, setList] = useState(countryNames[locale] || enUS);
|
||||
|
||||
async function loadData(locale: string) {
|
||||
const data = await httpGet(`${process.env.basePath || ''}/intl/country/${locale}.json`);
|
||||
const { data } = await httpGet(`${process.env.basePath || ''}/intl/country/${locale}.json`);
|
||||
|
||||
if (data) {
|
||||
countryNames[locale] = data;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export function useLanguageNames(locale) {
|
|||
const [list, setList] = useState(languageNames[locale] || enUS);
|
||||
|
||||
async function loadData(locale) {
|
||||
const data = await httpGet(`${process.env.basePath || ''}/intl/language/${locale}.json`);
|
||||
const { data } = await httpGet(`${process.env.basePath || ''}/intl/language/${locale}.json`);
|
||||
|
||||
if (data) {
|
||||
languageNames[locale] = data;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ export function useLocale() {
|
|||
const dateLocale = getDateLocale(locale);
|
||||
|
||||
async function loadMessages(locale: string) {
|
||||
messages[locale] = await httpGet(`${process.env.basePath || ''}/intl/messages/${locale}.json`);
|
||||
const { data } = await httpGet(`${process.env.basePath || ''}/intl/messages/${locale}.json`);
|
||||
|
||||
messages[locale] = data;
|
||||
}
|
||||
|
||||
async function saveLocale(value: string) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export function MetricsTable({
|
|||
return filter(arr);
|
||||
}, items);
|
||||
} else {
|
||||
items = dataFilter(data);
|
||||
items = dataFilter(items);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue