axios封装

2023-08-16 08:49:08 浏览数 (1)

代码语言:javascript复制
import axios from 'axios';

const http_url = "https://xxx.xxx.com"

// get请求
export function getRequest(url, sendData) {
    return new Promise((resolve, reject) => {
        axios.get(http_url   url, {params: sendData}).then(res => {
            resolve(res.data);
        }).catch(error => {
            reject(error);
        })
    })
}

// post请求
export function postRequest(url, sendData) {
    return new Promise((resolve, reject) => {
        axios.post(http_url   url, sendData).then(res => {
            resolve(res.data);
        }).catch(error => {
            reject(error);
        })
    })
}

0 人点赞