I m using Bearer token in my reactjs project and getting token form localstorage but space not coming properly between Bearer and Token
Code
const TOKEN = localStorage.getItem('TOKEN');
Axios.defaults.headers.common['Authorization'] = `Bearer ${TOKEN}`;
Result
Authorization: BearerN1ZuxkpgOlOfMGK3hrsl9N4UveoX-67hDH6jRDc5DgEA5yZpDxdyorIMCAeDV5vmHndKsapoYEqiXtoEPzT4vk6FQNOiQQRGdybZ-kfayEF2UaN7IJF0ui1nC8-hfpuzQddzBCg9PoskBzUJCc5ajYzp9VSNmo-nGtigEpyiqw7A5HDxi8GGytvkCGsM0-feW3FEy05VSKzkSu8pxTHR_Ism_uTTIxjrhiOEzMka5-qbhSQyTV1b5B_n_f_gsYX2
2
Answers
Your code formatter like
prettier
must be removing the space. In meantime you could use this lineThat’s the correct way to define the header.