Please excuse the beginner level question here, but on day 2 of Google searching and trying every permutation I can still not making progress on understanding why things are running the order they are.
Given the following code:
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
var username = await rl.question("Pleaser enter username\n");
await axios
.get('https://somewhere.net/api/something/', {
headers: {
Username: username
}
})
.then(res => {
console.log('statusCode: '+ res.status)
console.log(res.data.response)
})
.catch(error => {
console.error(error)
})
rl.close();
Why am I getting a Username undefined before it even prompts the user for input? I would expect to ask the user for input, then run the axios.