Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

What are "res" and "req" parameters in Express functions

app.get('/user/:id', function(request, response){
  response.send('user ' + request.params.id);
});
Comment

What are "res" and "req" parameters in Express functions

app.get('/people.json', function(request, response) {
  // We want to set the content-type header so that the browser understands
  //  the content of the response.
  response.contentType('application/json');

  // Normally, the data is fetched from a database, but we can cheat:
  var people = [
    { name: 'Dave', location: 'Atlanta' },
    { name: 'Santa Claus', location: 'North Pole' },
    { name: 'Man in the Moon', location: 'The Moon' }
  ];

  // Since the request is for a JSON representation of the people, we
  //  should JSON serialize them. The built-in JSON.stringify() function
  //  does that.
  var peopleJSON = JSON.stringify(people);

  // Now, we can use the response object's send method to push that string
  //  of people JSON back to the browser in response to this request:
  response.send(peopleJSON);
});
Comment

What are "res" and "req" parameters in Express functions

app.get('/people.json', function(request, response) { });
Comment

PREVIOUS NEXT
Code Example
Javascript :: Creating New Block for blockchain 
Javascript :: javascript loading animation on button click 
Javascript :: javascript stack 
Javascript :: javascript json 
Javascript :: combineReducers. 
Javascript :: js embedded function 
Javascript :: sequelize change item 
Javascript :: mongoose save returns null id 
Javascript :: nodejs date add days 
Javascript :: create file object node js 
Javascript :: example custom theme material ui 
Javascript :: pass array as argument javascript 
Javascript :: discord js slash command 
Javascript :: dynamic routing 
Javascript :: Javascript async await & Promise 
Javascript :: array max value 
Javascript :: Importing From Export Default Module 
Javascript :: Event Delegation Example In JavaScript 
Javascript :: deploy node app to heroku 
Javascript :: react native asyncstorage setItem example 
Javascript :: vue on page link or anchor 
Javascript :: javascript problems 
Javascript :: javascript loop object key value 
Javascript :: js array modify element 
Javascript :: use next() in node js 
Javascript :: add new element to existing json object 
Javascript :: new useSelector 
Javascript :: ex:js 
Javascript :: how to edit image tags in javascript 
Javascript :: scribbletune 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =