I have an img tag in jsp page where the src path requires header parameters to pass to get the image. How can we achieve it?
You can now use fetch() to add your headers and then load the result into an <img>
:
const src = 'https://api.mywebsite.com/profiles/123/avatar';
const options = {
headers: {
'Some-Header': '...'
}
};
fetch(src, options)
.then(res => res.blob())
.then(blob => {
imgElement.src = URL.createObjectURL(blob);
});