axios封装

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);
        })
    })
}

 

posted @ 2023-08-15 16:54  WrYcF  阅读(9)  评论(0编辑  收藏  举报
Live2D