import axios, { AxiosInstance, AxiosResponse } from 'axios';


/**
 * 基于Axios框架实现的Http工具
 * @author wufl2019@qq.com
 * @date 2020-06-23
 */
export class HttpUtil {

    private readonly axios: AxiosInstance;

    constructor(_timeout: number = 3000) {
        this.axios = axios.create({
            timeout: _timeout
        });
    }

    /**
     * @desc get请求
     * @param {String} path 请求api路径
     * @param {Object} data 参数对象
     */
    async get(url: string, data: object = {}): Promise<AxiosResponse> {
        return await this.axios.get(url, { params: data })
    }
}


export default new HttpUtil()