@modyo/cli
Version:
Modyo CLI Command line to expose local development tools
23 lines (22 loc) • 893 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const axios_1 = tslib_1.__importDefault(require("axios"));
const debug_1 = tslib_1.__importDefault(require("debug"));
const debug = (0, debug_1.default)('request');
const apiClient = axios_1.default.create();
if (process.env.DEBUG) {
apiClient.interceptors.request.use((config) => {
debug(`request [${config.method}](${config.url}) headers`);
debug(config.headers);
return config;
});
apiClient.interceptors.response.use((response) => {
debug(`response [${response.config.method}](${response.config.url}) headers`);
debug(response.headers);
debug(`response [${response.config.method}](${response.config.url}) params`);
debug(response.config.params);
return response;
});
}
exports.default = apiClient;