user8734728
user8734728

Reputation:

NodeJS (Windows) - SyntaxError: missing X

Unless there's something I don't understand, this seems to say ")" is missing and it point to ")".

});
 ^

SyntaxError: missing ) after argument list

This is generated from Guru99's Express.js tutorial file:

var express = require('express');
var app = express();
app.route('/Node',get(function(req,res)
{
    res.send("Tutorial on Node");
});
post(function(req,res)
{
    res.send("Tutorial on Angular");
});
put(function(req,res)
{
    res.send('Welcome to Guru99 Tutorials');
}));

The code looks ok to me.

Edit:

The resulting webpage says: Cannot get Node

Upvotes: 1

Views: 39

Answers (1)

Aritra Chakraborty
Aritra Chakraborty

Reputation: 12552

The syntax is wrong, Please refer the doc for more info:

app.route('/book')
  .get(function (req, res) {
    res.send('Get a random book')
  })
  .post(function (req, res) {
    res.send('Add a book')
  })
  .put(function (req, res) {
    res.send('Update the book')
  })

So, in your case it will be:

var express = require('express');
var app = express();
app.route('/Node')
.get(function (req, res) {
  res.send("Tutorial on Node");
})
.post(function (req, res) {
  res.send("Tutorial on Angular");
})
.put(function (req, res) {
  res.send('Welcome to Guru99 Tutorials');
});

Upvotes: 1

Related Questions