import lodash from 'lodash'; import { configs } from '../auction/config'; const axios = require('axios-extra'); export class Request { constructor() {} private _configsAxios: any = { headers: { Cookie: configs.cookie, 'User-Agent': configs.ua, ACCEPT: configs.accept, }, }; private _total: number = 0; public get total(): number { return this._total; } get headers(): any { return this._configsAxios; } async doGet(url: string, headers: any = null): Promise { this._total++; const _headers = headers ? lodash.merge(this._configsAxios.headers, headers) : this._configsAxios; return await axios.get(url, _headers); } async doPost(url: string, data: any): Promise { this._total++; return await axios.post(url, data, this._configsAxios); } } export const request = new Request();