Search code examples
javascriptapicookiesaxiosfoursquare

The difference of the responses between axios and browser in Foursquare Places API for Venue Search


While I opened the following Foursqaure API request in the browser,

https://api.foursquare.com/v2/venues/search?near=tokyo&client_id=LBPXTL2OS0SAYRDFXR3AB0JDZSCQTFHQFTVTI4YATZ0HDFFX&client_secret=0EUYB2ZK4NEPZVFD4JAXFFCVXNW5Q1GSTILY45402QFSPFSF&v=20180323&limit=1&categoryId=4bf58dd8d48988d181941735

I got a venue with checkinsCount = 26788. But when I send a GET request for the same URL through axios like how I have done in the following codesandbox, I get a different response and the venue's checkinsCount = 0.

https://codesandbox.io/s/stoic-morning-8x2xs?file=/src/App.js

Could anyone tell me an explanation why there is a response difference?


Solution

  • So after some research I've found that article that says that check in data is no longer available through api.

    I was quite confused though why it is visible in my Chrome, so I've tested other environments like terminal, Firefox, Safari, and basically everywhere checkinsCount was zero. But I was not logged in foursquare developer portal in those environments so I've guessed they probably check your cookies or something.

    And that's seems exactly what they are doing, they have oauth_token cookie if you logged into developer portal, and if you have valid cookie then you will get some bonus data for some reason. If you have invalid cookie there will be an error in response. And if you don't have this cookie then some of the data, like checkinsCount will be unavailable

    That's why @JeffUk got 0 from the first time - he was not logged in the console.