javascript - Redirect to url with auth header -


i'm trying redirect protected resource. when press login button posts unprotected login api , returns token.

the other routes expect header "authorisation: bearer token" kind of deal, don't know how set header when redirect protected resource:

console.log("success logging in, token retrieved.."); window.localstorage.setitem('token', data.token); window.location.href = '/admin/'; // + '?token='+ data.token; 

i pass token in query, that's bit ugly in opinion have handle endpoint differently how others handled... don't want have use cookies.

is there way add header? maybe i'm going wrong...

the short answer is, can't this. have use query param.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -