mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 22:43:12 +08:00
24 lines
477 B
JavaScript
24 lines
477 B
JavaScript
const axios = require("axios");
|
|
|
|
module.exports = (baseURL, options = {}) => {
|
|
const defaultOptions = {
|
|
baseURL,
|
|
};
|
|
|
|
const opts = Object.assign({}, defaultOptions, options);
|
|
|
|
const http = axios.create(opts);
|
|
|
|
http.interceptors.response.use((response) => {
|
|
const { data } = response;
|
|
|
|
if (typeof data === "object" && !Array.isArray(data) && data !== null) {
|
|
if ("data" in data) return data.data.data;
|
|
}
|
|
|
|
return data;
|
|
});
|
|
|
|
return http;
|
|
};
|