我想从外部api获取pdf数据,并且该api需要身份验证。我在标题中设置了授权,但仍然收到“未授权(401)”响应。
var xhrArgs = {
url: 'my_url',
headers: {
"Authorization": "Basic Y29tbWVyY2VBcHA6R3JAeWJAckFwcHMu",
"accept": "application/pdf"
},
load: function(data){
// Replace newlines with nice HTML tags.
console.info(data);
},
error: function(error){
console.info("An unexpected error occurred: " + error);
}
}
// Call the asynchronous xhrGet
var deferred = dojo.xhrGet(xhrArgs);