Snippets Collections
app.get('/:character', (req, res) => { // !'/:variable means we return dynamic value
  // * creates a constant which stores return from request parameter character

  const chosen = req.params.character;

  // What does this log?
  // * console logs the above return from request
  console.log(req.params);
  console.log(chosen);
  // * ends function response
  res.json(chosen);
  res.end();
});
The following examples illustrate defining simple routes.

Respond with Hello World! on the homepage:
//get method for retrieving data.
app.get('/', function (req, res) {
  res.send('Hello World!')
})
 Save
Respond to POST request on the root route (/), the application’s home page:
//send method for sending data.
app.post('/', function (req, res) {
  res.send('Got a POST request')
})
 Save
Respond to a PUT request to the /user route:
//put request to 
app.put('/user', function (req, res) {
  res.send('Got a PUT request at /user')
})
 Save
Respond to a DELETE request to the /user route:

app.delete('/user', function (req, res) {
  res.send('Got a DELETE request at /user')
})
star

Fri Dec 04 2020 02:21:51 GMT+0000 (Coordinated Universal Time)

#nodejs,jquery,nodejs #nodejs,jquery
star

Fri Dec 04 2020 01:43:47 GMT+0000 (Coordinated Universal Time)

#nodejs,jquery #nodejs

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension