@noassl was correct with their comment. The real issue I was running into was with my incorrect assignment of the token. The authorization token was initially assigned undefined but I am not sure why I was unable to change it. I am assuming this has something to do with the way Axios instances function. To correct this issue, I moved the assignment of the instance inside the login function.
const fastify = require('fastify')({ logger: true });
const axios = require('axios');
const fs = require('fs');
require('dotenv').config();
const username = process.env.USERNAME
const password = process.env.PASSWORD
let token
let instance
async function login() {
const response = await axios.post('/login', {username, password})
token = response.data['token'];
instance = axios.create({
baseURL: process.env.URL,
headers : {
'Authorization': `Bearer ${token}`
}
})
console.log(token);
}
async function me() {
const response = await instance.get('/me')
console.log(response.data);
}
login().then(me())