import { getHosts } from "@/envHosts"; import {fetchUrl} from "@/config" class request { request(config: any) { return new Promise(async (resolve, reject) => { if (config.method == 'post') { config.body = JSON.stringify(config.data); } config.headers = { 'Content-Type': 'application/json', // 'Access-Token': // '22qTpDZa9xKK9B+4NW8UqCH/BCGfO8wJmNB4TDeY7AkP2WtHK7Fw3Fma82SSEs3b', ...config.headers, }; try { // const { Host00 } = getHosts(); const Host00 = fetchUrl const res = await fetch(`${Host00}${config.url}`, { ...config // cache: 'no-store' }); let response if(config.responseType != 'blob'){ response = await res.json(); }else { response = await res.blob(); } resolve(response); } catch (error) { reject(error); } }); } get(config: any) { return this.request({ ...config, method: 'get' }); } post(config: any) { return this.request({ ...config, method: 'post' }); } } const requestInstance = new request(); export default requestInstance;