Created
December 20, 2016 19:59
-
-
Save refo/2b5700f10ee97d73c2cad3efdb9c5a41 to your computer and use it in GitHub Desktop.
Foursquare Search API test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const | |
assert = require('assert'), | |
request = require('request'), | |
config = require('../config'), | |
_ = ''; | |
const foursq = { | |
req: request.defaults({ | |
baseUrl: 'https://api.foursquare.com/v2/', | |
method: 'GET', | |
headers: { | |
'Accept-Language': 'tr' | |
}, | |
qs: { | |
client_id: config.foursquare.client_id, | |
client_secret: config.foursquare.client_secret, | |
v: 20161101, | |
limit: 100, | |
radius: 50, | |
intent: "browse" | |
} | |
}), | |
search (lat, lng) { | |
if (!lng) { | |
[lat, lng] = lat.split(','); | |
} | |
this.req.get('/venues/search', { | |
qs: {ll: `${lat},${lng}`} | |
}, (err, res, body) => { | |
assert.equal(null, err); | |
this.processVenues(JSON.parse(body).response.venues); | |
}); | |
}, | |
processVenues (venues) { | |
venues.forEach(venue => { | |
console.log(venue.id, venue.name); | |
}); | |
} | |
}; | |
foursq.search('41.0825762,29.0098199'); | |
return 0; | |
const req = { | |
ll: "41.0825762,29.0098199" | |
}; | |
foursqReq.get('/venues/search', { | |
qs: req | |
}, (err, res, body) => { | |
console.log(body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment