mirror of
https://github.com/axios/axios.git
synced 2026-04-11 02:11:50 +08:00
* chore: remove all old and un-needed files * chore: fix missing file * chore: fix ref error * chore: add back missing file * chore: incorrect folder location * chore: ignore ts issues
25 lines
606 B
JavaScript
25 lines
606 B
JavaScript
import axios from '../index.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(
|
|
`[${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,
|
|
},
|
|
});
|