I have axios get request with basic auth, but i keep getting back a 401 status code. My code does work if i am doing a post request, so I don't know what i'm doing wrong here.
My backend code:
app.get('/api/find-user', (req, res) => {
const username = req.body.username;
axios.get('my-url', username, {
auth:{
username: 'my-username',
password: 'my-password'
}
})
.then(resp => {
res.json({resp});
})
.catch(error => {
res.send(error.response.status);
})
});
My frontend code:
findUser(user){
const username = user;
axios.get('/api/find-user', {username})
.then(resp => {
console.log(resp);
})
.catch(error => {
console.log(error)
})
}
Again when i am doing a post to create a new user it does work, but when i am doing a GET request it keeps saying i am not authorized.
Edit: If you feel like downvoting be adult enough to explain why.