UNPKG

@dlillyatx/dc-cli

Version:
39 lines (38 loc) 1.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AxiosHttpClient = void 0; const axios_1 = __importDefault(require("axios")); class AxiosHttpClient { constructor(config) { this.config = config; this.client = axios_1.default.create(config); } request(config) { return this.client .request({ data: config.data, headers: config.headers, method: config.method, url: config.url }) .then(response => { return { data: response.data, status: response.status }; }) .catch(error => { if (error && error.response) { return { data: error.response.data, status: error.response.status }; } return error; }); } } exports.AxiosHttpClient = AxiosHttpClient;