-
Notifications
You must be signed in to change notification settings - Fork 0
/
yelpLocation.js
50 lines (44 loc) · 1.21 KB
/
yelpLocation.js
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
45
46
47
48
49
50
const apiKey =
"VOFrlTItWh9XawE_uJ12b0moG-009HKnslg6ceXkkvcRXBi-613Ui6eTqMbuqXBvay4plE4ijOJK2ABa27x1ANnXoaepMEo1OVFD7nrcuYwtSFPdkiHq4EUd6FdkW3Yx";
const yelp = require("yelp-fusion");
const client = yelp.client(apiKey);
function getPlacesYelp(name, location) {
return client
.search({
term: name, // first name , last name
location: location // location
})
.then(res => {
// console.log(res);
if (res.jsonBody.businesses.length > 0) {
let results = res.jsonBody.businesses[0].location.display_address;
console.log(results);
return results;
} else {
return false;
}
})
.catch(e => {
console.log(e.message);
return false;
});
}
// getPlacesYelp("Flynn Construction Austin Texas").then(res => {
// console.log(res);
// });
async function getYelpData(data) {
return client
.business(data)
.then(response => {
let url = response.jsonBody.url;
console.log(url);
//console.log(response.jsonBody);
return url;
})
.catch(e => {
console.log(e);
return null;
});
}
//getYelpData("Flynn Construction Austin Texas");
module.exports = { getLocationYelp: getPlacesYelp, getYelpData };