问题描述
我试图将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(); }
推荐答案
问题是缺少的'?'在场地ID之后和用户凭据之前的嵌套请求URL中.
doh,只需要用静止的眼睛凝视更长的时间.
问题描述
I'm trying to pass Foursquare venue details to a Venue listing page (parent) but am receiving an error from the nested function that pulls the details. The initial listing request returns data as expected without error. How can I resolve the authentication error on the nested request?
This is the error -
{ code: 400 errorDetail: "Missing access credentials. See https://developer.foursquare.com/docs/api/configuration/authentication for details." errorType: "invalid_auth" }
I'm calling this function within the listing function -
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(); }
Here is the listing function -
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(); }
推荐答案
The problem was a missing '?' in the nested request URL after the venue ID and before the user credentials.
DOH, just needed to stare at it longer with rested eyes.