import Taro from '@tarojs/taro'
import {getSignTokenBody} from "./getToken";
/* eslint-disable-next-line no-undef */
const getRemoteApi = () => {
let remoteApi = '';
if (process.env.NODE_ENV === 'development') {
remoteApi = 'http://127.0.0.1:8088/exam';
} else {
remoteApi = 'http://xxx.xxx.xxx:8080/exam/exam';
}
return remoteApi;
};
export const apiHost = getRemoteApi()
const api = {
baseOptions (params, method = 'POST') {
const { url, data, contentType = 'application/x-www-form-urlencoded;application/json; charset=utf-8' } = params
const isFullURl = url.startsWith('http') || url.startsWith('https');
let requestUrl = url;
if (!isFullURl) {
requestUrl = `${apiHost}${url}`;
}
const options = {
url: requestUrl,
data,
method,
header: {
基于taro3.x - react.js redux,开发h5 小程序 api请求封装 (三)
最新推荐文章于 2023-11-29 10:37:41 发布