wundertec-core
Version:
Librería estándar de utilidades e integraciones AWS + helpers generales
37 lines (36 loc) • 1.29 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AxiosClient = void 0;
const axios_1 = __importDefault(require("axios"));
class AxiosClient {
constructor(config) {
this.client = axios_1.default.create({
timeout: config?.timeout || 5000,
...config,
});
}
/** Realiza una petición GET y retorna los datos */
async get(url, config) {
const response = await this.client.get(url, config);
return response.data;
}
/** Realiza una petición POST con datos y retorna los datos */
async post(url, data, config) {
const response = await this.client.post(url, data, config);
return response.data;
}
/** Realiza una petición PUT y retorna los datos */
async put(url, data, config) {
const response = await this.client.put(url, data, config);
return response.data;
}
/** Realiza una petición DELETE y retorna los datos */
async delete(url, config) {
const response = await this.client.delete(url, config);
return response.data;
}
}
exports.AxiosClient = AxiosClient;