const axios = require('axios');
require('dotenv').config();
const apiUsers = async (req, res) => {
let { since } = req.query
const { data, headers } = await axios.get(`https://api.github.com/users?since=${since}`,
headers: {
'Authorization': 'token' process.env.AUTH_TOKEN
}
});
Result = enter image description here
if the token is passed correctly, the request limit should be 5000
My .env archive below: enter image description here
CodePudding user response:
I think you have formatted your header incorrectly, it should be:
'Authorization': 'Bearer ' process.env.AUTH_TOKEN
You also appear to have mismatched environment variables. You access AUTH_TOKEN
in your code but its just TOKEN
in your env file - make sure these variable names are the same.
CodePudding user response:
Solved In this case the answer is 'Authorization': 'token ' process.env.AUTH_TOKEN The problem is the empty space after token... i forgot, but now is right!