UNPKG

@amirmarmul/waba-common

Version:

![GitHub release](https://img.shields.io/github/v/release/amirmarmul/waba-common?style=flat-square)

32 lines (31 loc) 1.18 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.axios = void 0; const axios_1 = __importDefault(require("axios")); const axios_curlirize_1 = __importDefault(require("axios-curlirize")); exports.axios = axios_1.default.create({ headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', } }); exports.axios.interceptors.request.use(function (config) { // Do something before request is sent return config; }, function (error) { // Do something with request error return Promise.reject(error); }); exports.axios.interceptors.response.use(function (response) { // Any status code that lie within the range of 2xx cause this function to trigger // Do something with response data return response.data; }, function (error) { // Any status codes that falls outside the range of 2xx cause this function to trigger // Do something with response error return Promise.reject(error); }); (0, axios_curlirize_1.default)(exports.axios);