I am using ember vesrion 2.15.1 for my application. I am using ember-file-upload node module to support file upload and that is successful. Challenge is I am not able to add auth token to the request header. My request header looks like this:
I am not able to add userAuthToken in request header of file upload like below which I am able to add for other api calls:
I have tried uploading the file via
set(file, 'headers.userAuthToken', localStorage.getItem("userToken")); // this line is creating problems
let response = yield file.upload(url);
But unable to add userAuthToken in request header. Any fix or workaround will be appreciated.
You can pass options as second parameter of upload
method. One of possible options is headers
. Something like this should work:
let response = yield file.upload(url, {
headers: {userAuthToken: localStorage.getItem("userToken")}
});
You can find other possible options here