Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Postman for POST request #7

Closed
github-learning-lab bot opened this issue Nov 26, 2020 · 1 comment
Closed

Use Postman for POST request #7

github-learning-lab bot opened this issue Nov 26, 2020 · 1 comment

Comments

@github-learning-lab
Copy link

We can make GET requests all day through the browser url, but to make a POST request, we need to get more sophisticated! Open up the PostMan App, and look for an input field that says: "Enter Request Url". It is between a dropdown menu and a Send button.

screenshot of postman

First, change the dropdown on the upper left from GET to POST. Next, enter our login url next to the dropdown (http://localhost:8000/login). Before you hit send, we need to change a few things.

Click the "Headers" tab, and enter the key: Content-Type. In the box just to the right, enter the value: application/json. This tells the server the request is going to be in JSON format.

Next, click on the "Body" tab. In the dropdown below, change the value to "raw", and enter the login data below:

{
"username":"billyTheKid",
"password":"superSecret"
}

Restart your server, to make sure you have the latest version running (with body-parser and our post function). Click send in PostMan, and you should get a positive response from the server.

When you get a response, close this issue for the next step.

@github-learning-lab
Copy link
Author

Good Job! 🚀 Postman can be a really helpful testing tool as you continue your programming journey.

Before closing out this course, try a few more things in Postman:

  • Change the password value in the body tab to see what an incorrect password response looks like
  • Try our earlier requests that we made from the browser (remember to switch to GET in Postman)
  • See if you can make a new endpoint in the server.js code, then call it from Postman

Click here for one final issue to plan your next steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant