const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run' const useFetchRequest = (baseUrl) => { baseUrl = baseUrl || BASE_URL const config = { headers: {} } const fetchRequest = (url, fetchConfig) => { url = `${baseUrl}${url}` fetchConfig = fetchConfig || {} fetchConfig.headers = fetchConfig.headers || {} if (window && window.localStorage) { fetchConfig.headers.Authorization = localStorage.getItem('token') } fetchConfig.method = (fetchConfig.method || 'get').toLocaleUpperCase() fetchConfig = Object.assign(config, fetchConfig) return new Promise((resolve, reject) => { $fetch(url, fetchConfig).then((result) => { resolve(result) }).catch(() => { resolve(null) }) }) } return { fetchRequest } } export default useFetchRequest