javascript - How to pass value stored in browser local storage to browser initiated request? -


i have stored value in browser local storage

window.localstroage.setitem(key,'value-x'); 

how pass 'value-x' in custom request header? [using javascript] e.g need pass stored value image request.

<img src="some/url" />  

how set custom header 'value-x' in 'some/url' request (which initiated browser)?

you can't.

the time can set http header programmatically when making request javascript via xmlhttprequest or fetch. there's no way when request made insertion of <img> element.

the closest come here make request using xhr, convert response data: scheme uri, , populate src attribute that.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -