Using Postman to query Node endpoints

start up your server


> node server.js

Then the output from the terminal would be like this:

Insert beer on port 3000
mongoose db connected

Use postman to send data

Make sure you select POST as your request verb.

type in the test url:
http://localhost:3000/api/

Select Body, because we are using POST data from a web form.

The body data comes from a x-www-form-urlencoded

For application/x-www-form-urlencoded, the body of the HTTP message sent to the server is essentially one giant query string — name/value pairs are separated by the ampersand (&), and names are separated from values by the equals symbol (=). An example of this would be:

MyVariableOne=ValueOne&MyVariableTwo=ValueTwo

This query string is stored in the BODY of the message packet.

So in POSTMAN, just put test as the key, and please work as the value.

postman-post

When you press “Send” in POSTMAN, you should see the output from your node terminal like so:


POST /api/
{ test: ‘please work’ }
{}
{}

As you can see, the results appear in req.body