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'
|
||||
|
||||
const apiEndpoint =
|
||||
'https://' +
|
||||
(process.dev
|
||||
? useRuntimeConfig().public.apiIp || window.location.hostname
|
||||
: window.location.hostname) +
|
||||
'/yunohost/portalapi'
|
||||
const useApiEndpoint = () => {
|
||||
return (
|
||||
'https://' +
|
||||
(process.dev
|
||||
? useRuntimeConfig().public.apiIp || window.location.hostname
|
||||
: window.location.hostname) +
|
||||
'/yunohost/portalapi'
|
||||
)
|
||||
}
|
||||
|
||||
export function useApi<T>(
|
||||
path: string,
|
||||
|
@ -27,7 +30,7 @@ export function useApi<T>(
|
|||
}
|
||||
|
||||
const query = () => {
|
||||
return $fetch(apiEndpoint + path, {
|
||||
return $fetch(useApiEndpoint() + path, {
|
||||
method,
|
||||
credentials: 'include',
|
||||
body,
|
||||
|
|
Loading…
Add table
Reference in a new issue