mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 12:47:13 +01:00
Support basePath in all queries.
This commit is contained in:
parent
2508198a51
commit
5068ab12a9
11 changed files with 57 additions and 29 deletions
|
|
@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
|
|||
import { useDispatch } from 'react-redux';
|
||||
import { get } from 'lib/web';
|
||||
import { updateQuery } from 'redux/actions/queries';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
export default function useFetch(url, params = {}, options = {}) {
|
||||
const dispatch = useDispatch();
|
||||
|
|
@ -9,6 +10,7 @@ export default function useFetch(url, params = {}, options = {}) {
|
|||
const [status, setStatus] = useState();
|
||||
const [error, setError] = useState();
|
||||
const [loading, setLoadiing] = useState(false);
|
||||
const { basePath } = useRouter();
|
||||
const keys = Object.keys(params)
|
||||
.sort()
|
||||
.map(key => params[key]);
|
||||
|
|
@ -19,7 +21,7 @@ export default function useFetch(url, params = {}, options = {}) {
|
|||
setLoadiing(true);
|
||||
setError(null);
|
||||
const time = performance.now();
|
||||
const { data, status } = await get(url, params);
|
||||
const { data, status } = await get(`${basePath}${url}`, params);
|
||||
|
||||
dispatch(updateQuery({ url, time: performance.now() - time, completed: Date.now() }));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue