我正在尝试将Foursquare场地详细信息传递到“场地”列表页面(父级),但是从嵌套函数中接收到一个错误,该错误提取了详细信息。初始列表请求将按预期返回数据,而不会出现错误。如何解决嵌套请求上的身份验证错误?
这是错误-
{
code: 400
errorDetail: "Missing access credentials. See
https://developer.foursquare.com/docs/api/configuration/authentication
for details."
errorType: "invalid_auth"
}
我在列表函数中调用此函数-
var request = new XMLHttpRequest();
function getDetails(e){
requestVenueDetails = 'https://api.foursquare.com/v2/venues/'+e+'&client_id='+{client id}+'&client_secret='+{secret}+'&v='+{version};
request.open('GET', requestVenueDetails, true);
request.onload = function()
{
var detailsData = JSON.parse(this.response);
var venueDetails = detailsData;
console.log(venueDetails, ' return confirmation message');
}
request.send();
}
这是列表功能-
returnRequest = function(){
request.onload = function()
{
var data = JSON.parse(this.response);
var venues = data.response.venues;
console.log(venues);
if(venues.length>0)
{
venues.forEach( venue=> {
if((venue.location.address != null) && (venue.verified = true))
{
getDetails(venue.id);
{listing html here}
}
});
}
request.send();
}
答案 0 :(得分:0)
问题是缺少“?”在嵌套的请求URL中,在场所ID之后,在用户凭据之前。
DOH,只需要休息一下眼睛凝视它。