按照我之前的post,我正在
XHR finished loading: POST "http://partners.api.skyscanner.net/apiservices/pricing/v1.0".
似乎POST工作正常,但对于GET:
GET
http://testdomain.com:3000/undefined?apiKey=APIKEY&stops=0&duration=360&includeCarriers=ba;u2;af
404 (Not Found)
Uncaught (in promise) Error: Request failed with status code 404
at createError (bundle.js:23687)
at settle (bundle.js:23657)
at XMLHttpRequest.handleLoad (bundle.js:23529)
这是代码的一部分:
axios(authOptions)
.then(function(response){
console.log("response ====> ", response.headers);
console.log("--->", response.headers.Location);
/*
console.log("data is: ", response.data);
console.log("response.request.responseURL: ", response.request.responseURL );
console.log("response headers", response.headers);
console.log("location headers: ", response.headers.location);
*/
var newAuthOpts = {
method: 'GET',
url: response.headers.Location + '?apiKey=APIKEY&stops=0&duration=360&includeCarriers=ba;u2;af',
data: querystring.stringify(data),
json: true
};
axios(newAuthOpts).then(function(response) {
console.log(response);
});
})
.catch(function(error){
console.log(error);
});
return {
type: FETCH_LOCALS,
payload: data
};
我正在尝试从标题中获取正确的url:response.headers.location
,但这会返回undefined,我找不到错误。有人可以帮忙吗?
答案 0 :(得分:0)
response.headers.location
和response.headers.Location
之间存在很大差异 - JavaScript中的所有内容都区分大小写。换句话说,两个版本可以共存并被视为完全不同的属性。因此,通常使用camelCase。通过这种方式,例如,当一个属性以大写字母开头时,我们可以很容易地将其识别为错误。