-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (23 loc) · 772 Bytes
/
index.js
File metadata and controls
35 lines (23 loc) · 772 Bytes
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
const express = require('express');
const app = express();
const axios = require('axios');
const cors = require('cors');
const yelp = require('yelp-fusion');
const client = yelp.client('e9c0h_ProzTzLLvzGUKgtExE14Z6v8MSsiTPsRzn-CpTE8fuB5G0BHutoLUlfsu8sLkIxS-wvdFz-CIDeRqTSWuEMauCGD2ZeipcRK-EPsOE_oV3tTg0OOdqD2UXXXYx');
app.use(cors())
app.get('/' , (req , res,next) => {
const latitude = req.query.lat;
const longitude = req.query.lng;
client.search({
term: "restaurants",
latitude: latitude,
longitude: longitude
}).then(response => {
res.status(200).json(JSON.parse(response.body));
}).catch(e => {
console.log(e);
});
});
app.listen(8000 , () => {
console.log('App is working');
})