I am currently facing a syntax error in the code below, and I'm struggling to fix it.
The specific error message 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
I understand how to create a route that accepts parameters for cities in general, but I'm unsure how to filter JSON results specifically by a certain city. For example, filtering restaurants in Delhi only.
const app = express();
const port = 8700;
var location = [
{
"id": 1,
"name": "Pitampura, New Delhi",
"city_name": "Delhi",
"city": 1,
"area": 11,
"country_name": "India",
},
// More location data here...
];
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}`)
}))