Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

space issue in bearer token in react js

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Authorization: BearerN1ZuxkpgOlOfMGK3hrsl9N4UveoX-67hDH6jRDc5DgEA5yZpDxdyorIMCAeDV5vmHndKsapoYEqiXtoEPzT4vk6FQNOiQQRGdybZ-kfayEF2UaN7IJF0ui1nC8-hfpuzQddzBCg9PoskBzUJCc5ajYzp9VSNmo-nGtigEpyiqw7A5HDxi8GGytvkCGsM0-feW3FEy05VSKzkSu8pxTHR_Ism_uTTIxjrhiOEzMka5-qbhSQyTV1b5B_n_f_gsYX2

>Solution :

Your code formatter like prettier must be removing the space. In meantime you could use this line

Axios.defaults.headers.common['Authorization'] = 'Bearer'+' '+TOKEN;

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading