1
0
term/pkg/axios/bin/githubAxios.js

20 lines
624 B
JavaScript
Raw Normal View History

2024-03-23 11:25:41 +00:00
import axios from '../index.js';
import {colorize} from "./helpers/colorize.js";
const {GITHUB_TOKEN} = process.env;
GITHUB_TOKEN ? console.log(`[GITHUB_TOKEN OK]`) : console.warn(`[GITHUB_TOKEN is not defined]`);
const defaultTransform = axios.defaults.transformRequest;
export default axios.create({
transformRequest: [defaultTransform[0], function (data) {
console.log(colorize()`[${this.method.toUpperCase()}] Request [${new URL(axios.getUri(this)).pathname}]`);
return data;
}],
baseURL: 'https://api.github.com/',
headers: {
Authorization: GITHUB_TOKEN ? `token ${GITHUB_TOKEN}` : null
}
});