This code below is throwing a syntax error that I cannot seem to rectify.
The error specifically is as follows:
node staticapi.js
/Users/v/Desktop/CS-Extra/EIP/A5/staticapi.js:123
res.status(200).send(“Api is running”)
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:1152:16)
at Module._compile (internal/modules/cjs/loader.js:1200:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
at Module.load (internal/modules/cjs/loader.js:1085:32)
at Function.Module._load (internal/modules/cjs/loader.js:950:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
Also i know how to create a route to accept the parameter for city in general but how do i create a route which filters my json result based on a specific city. Not just by cities in general but instead filter json by restaurants in Delhi per se.
const app = express();
const port = 8700;
var location = [
{
"_id": 1,
"name": "Pitampura, New Delhi",
"city_name": "Delhi",
"city": 1,
"area": 11,
"country_name": "India",
},
{
"_id": 2,
"name": "Ashok Vihar Phase 2",
"city_name": "Delhi",
"city": 1,
"area": 12,
"country_name": "India",
},
{
"_id": 3,
"name": "Laxmi Nagar",
"city_name": "Delhi",
"city": 1,
"area": 13,
"country_name": "India",
},
{
"_id": 4,
"name": "Lajpat Nagar 2",
"city_name": "Delhi",
"city": 1,
"area": 14,
"country_name": "India",
},
{
"_id": 5,
"name": "Borivali West",
"city_name": "Mumbai",
"city": 2,
"area": 21,
"country_name": "India",
},
{
"_id": 6,
"name": "Mira Road",
"city_name": "Mumbai",
"city": 2,
"area": 22,
"country_name": "India",
},
{
"_id": 7,
"name": "Sion",
"city_name": "Mumbai",
"city": 2,
"area": 23,
"country_name": "India",
},
{
"_id": 8,
"name": "Mohammad Ali Road",
"city_name": "Mumbai",
"city": 2,
"area": 24,
"country_name": "India",
},
{
"_id": 9,
"name": "Magarpatta",
"city_name": "Pune",
"city": 3,
"area": 31,
"country_name": "India",
},
{
"_id": 10,
"name": "Koregaon Park",
"city_name": "Pune",
"city": 3,
"area": 32,
"country_name": "India",
},
{
"_id": 11,
"name": "Rajajinagar",
"city_name": "Bangalore",
"city": 4,
"area": 41,
"country_name": "India",
},
{
"_id": 12,
"name": "Koramangala 6th Block",
"city_name": "Bangalore",
"city": 4,
"area": 42,
"country_name": "India",
},
{
"_id": 13,
"name": "Sector70, Chandigarh",
"city_name": "Chandigarh",
"city": 5,
"area": 51,
"country_name": "India",
},
{
"_id": 14,
"name": "Sector 28, Chandigarh",
"city_name": "Chandigarh",
"city": 5,
"area": 52,
"country_name": "India",
}
];
var cuisine = [abc];
app.get(`/`,(req, res) (function() {
res.status(200).send(“Api is running”)
}));
app.get(`/location`(req, res)(function () {
res.status(200).send(location)
}))
app.get(`/cuisine`(req, res)(function () {
res.status(200).send(cuisine)
}))
app.listen(port, (function (err) {
if (err) throw err;
console.log(`Server is running ${port}`)
}))```