import request from './request'; import regeneratorRuntime from '@/common/static/lib/runtime'; import config from '../config'; const endpoints = { getUploadToken: (data) => ({ isQiniu: true, path: '/upload/getUploadToken', data, method: 'POST', }), }; const getHost = (requestOptions) => { const { newUrl } = config; if (requestOptions.isQiniu) { return newUrl+"elab-marketing-file"; } return newUrl+"elab-wuxi-project"; }; export default async (endpoint, ...options) => { if (!endpoints.hasOwnProperty(endpoint)) { console.error(`no such endpoint: ${endpoint}`); return; } const requestOptions = endpoints[endpoint].apply(null, options); requestOptions.url = getHost(requestOptions) + requestOptions.path; const response = await request(requestOptions); console.log({ url: requestOptions.url, req: requestOptions, res: response }); return response; }