I am trying to execute a command using node JavaScript, but I am getting "Uncaught SyntaxError: Unexpected token ILLEGAL" in my javascript.Its on line 1.
var express = require('express');
var mongodb = require('mongodb');
var app = express();
var MongoClient = require('mongodb').MongoClient;
var db;
var port = process.env.PORT || 8080;
MongoClient.connect(mongo_host, function(err, database) {
if(err) throw err;
db = database;
app.listen(port, function () {
console.log('listening port' + port);
});
});
app.get('/', function (req, res) {
res.json({ message: 'Bienvenue Azure!' });
});
app.get('/plante', function (req, res) {
db.collection("plante").find().toArray(function(err, users) {
res.send(users);
});
});
NB: mongo_host is the Git repository url to connect with azure
Then it is showing the following error:
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
at node.js:974:3