-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
49 lines (38 loc) · 1.23 KB
/
main.js
File metadata and controls
49 lines (38 loc) · 1.23 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
45
46
47
48
49
const secrets = require('./secrets')
const express = require('express')
const bodyParser = require('body-parser')
const apiai = require('apiai')
// using apiai token
// const app = apiai(secrets.apiAi)
// const request = app.textRequest('what is the weather in nyc', {
// sessionId: 'Where to get this sessionId?'
// })
// request.on('response', function(response) {
// // console.log(response);
// console.log(response)
// })
// request.on('error', function(error) {
// console.log(error)
// })
// request.end()
const yelp = require('yelp-fusion');
// const secrets = require('../secrets')
// Place holders for Yelp Fusion's OAuth 2.0 credentials. Grab them
// from https://www.yelp.com/developers/v3/manage_app
const clientId = secrets.yelpClientId;
const clientSecret = secrets.yelpClientSecret;
const searchRequest = {
categories:'japanese',
location: '11228',
limit: 5,
};
yelp.accessToken(clientId, clientSecret).then(response => {
const client = yelp.client(response.jsonBody.access_token);
client.search(searchRequest).then(response => {
const firstResult = response.jsonBody.businesses;
const prettyJson = JSON.stringify(firstResult, null, 4);
console.log(prettyJson);
});
}).catch(e => {
console.log(e);
});