-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-test.js
More file actions
44 lines (33 loc) · 1.06 KB
/
api-test.js
File metadata and controls
44 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const yelp = require('yelp-fusion');
const API_KEY = "fFoHEGbf5qO3BdOMbgSY174VNDVnntD3kiyiznj5tUnCpTLvQICJwcfKqKbuHm9yaJRjP0hs2K73gHO1es1X3faeCtFc80fWZ6NwnDV9R2FeGN5qq5jI8Ku1EjydW3Yx";
const client = yelp.client(API_KEY);
const request = require('request');
function pick_random(array){
return array[Math.round(Math.random() * array.length)]
}
function event_search(location){
var query = {
url : "https://api.yelp.com/v3/events?location=" + location,
headers : {
'Authorization' : 'Bearer ' + API_KEY
}
}
request(query, function(err, response, body){
var jsonBody = JSON.parse(body);
console.log(jsonBody);
})
}
function venue_search(location, term){
const MAX_DISTANCE = 22530;
var query = {
url : "https://api.yelp.com/v3/businesses/search?location=" + location + '&term=' + term + '&limit=50&radius=' + MAX_DISTANCE,
headers : {
'Authorization' : 'Bearer ' + API_KEY
}
}
request(query, function(err, response, body){
var jsonBody = JSON.parse(body);
console.log(jsonBody);
})
}
event_search('houston');