mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
turn apiEndpoint into composable to avoid nuxt context errors
This commit is contained in:
parent
535dd0e0c5
commit
46a76ff4bc
1 changed files with 10 additions and 7 deletions
|
@ -1,11 +1,14 @@
|
||||||
import type { FetchError } from 'ofetch'
|
import type { FetchError } from 'ofetch'
|
||||||
|
|
||||||
const apiEndpoint =
|
const useApiEndpoint = () => {
|
||||||
'https://' +
|
return (
|
||||||
(process.dev
|
'https://' +
|
||||||
? useRuntimeConfig().public.apiIp || window.location.hostname
|
(process.dev
|
||||||
: window.location.hostname) +
|
? useRuntimeConfig().public.apiIp || window.location.hostname
|
||||||
'/yunohost/portalapi'
|
: window.location.hostname) +
|
||||||
|
'/yunohost/portalapi'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export function useApi<T>(
|
export function useApi<T>(
|
||||||
path: string,
|
path: string,
|
||||||
|
@ -27,7 +30,7 @@ export function useApi<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = () => {
|
const query = () => {
|
||||||
return $fetch(apiEndpoint + path, {
|
return $fetch(useApiEndpoint() + path, {
|
||||||
method,
|
method,
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
body,
|
body,
|
||||||
|
|
Loading…
Add table
Reference in a new issue