chore: update frontend configuration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useToast } from './useToast'
|
||||
|
||||
export function useApi() {
|
||||
export function useApi () {
|
||||
const { showSuccess, showError, showInfo } = useToast()
|
||||
const { public: publicConfig } = useRuntimeConfig()
|
||||
const API_BASE_URL = publicConfig.apiBaseUrl || 'http://localhost:3000'
|
||||
@@ -11,8 +11,8 @@ export function useApi() {
|
||||
const url = `${API_BASE_URL}${endpoint}`
|
||||
const defaultOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter un timeout à la requête
|
||||
@@ -20,14 +20,14 @@ export function useApi() {
|
||||
const timeoutId = setTimeout(() => controller.abort(), API_TIMEOUT)
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
...defaultOptions,
|
||||
const response = await fetch(url, {
|
||||
...defaultOptions,
|
||||
...options,
|
||||
signal: controller.signal
|
||||
})
|
||||
|
||||
|
||||
clearTimeout(timeoutId)
|
||||
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
return { success: true, data }
|
||||
|
||||
Reference in New Issue
Block a user