I'm using vue3 with axios and prisma, but I have a problem getting user info.
My postman request is ok (http://localhost:3000/api/auth/user/7), but my axios req is not.
Can you help me please ?
async created () {
const response = await axios.get('http://localhost:3000/api/auth/user/:id', {
headers: {
Authorization: 'Bearer ' + localStorage.getItem('token')
}
});
console.log('ici');
}
Axios does not support URL parameters.
One solution would be to use template strings to build the request URL.
For example:
function getID(id) {
const response = await axios.get(`http://localhost:3000/api/auth/user/${id}`,{
headers: {
Authorization: 'Bearer ' + localStorage.getItem('token')
}
});
}
// getID(7);