While working on implementing authorization, I encountered an error from Ts-eslint stating that there was an "Invalid type 'string | null' of template literal expression" when trying to execute the functionality.
The data being retrieved from localstorage can either be 'null' or a 'string', but it also needs to be combined with 'Bearer' for authentication.
onMounted(async() => {
let myToken = localStorage.getItem('token');
await axios.post(
'http://localhost:3000/getdocuments',
{headers:{'Authorization': `Bearer ${myToken}`}}
)
.then((res) => {
console.log(res);
})
.catch(err => {
console.log(err);
})
})