Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Full stack web development Course | 116. Swag Shop API: Posting Products
Play lesson

Full Stack Web Development Tutorial Course - Full stack web development Course | 116. Swag Shop API: Posting Products

4.0 (3)
36 learners

What you'll learn

This course includes

  • 26.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

Full-stack web development Tutorial in Just 3 Weeks Week 3: Day 2 Section 12: Intro to Node, Mongo, & REST APIs Tutorial 116: Swag Shop API: Posting Products In this video tutorial, we are going to learn to add data to our Mongo shell using post request and check it on POSTMAN. LECTURE CONTENT 00:00:00 Introduction 00:02:05 Creating a Post request 00:08:40 Checking the post request in POSTMAN 00:11:25 Exit command 00:12:43 End Step 1: Add the new product to the collection using app.post('/collection' , function(request,response){} The post is an HTTP method used when we need to send some additional information inside the body of the request to the server. / is the path or route The function is the middleware function. The middleware function is a function that has access to the request object, response object, and the next function in the applications request-response cycle. These functions are used to modify request and response objects for tasks like parsing request body, adding response headers, etc. Request(req) is the HTTP request argument to the middleware function Response(res)is the HTTP response argument for the middleware function Example- app.post('/product',function(request,response){error message}); Step 2: Enter the message to be displayed to the user the product is saved or not saved. If it is saved it will display "saved product" but if not saved it will display "could not save product". Step 3: Open POSTMAN. Check the post request in POSTMAN. Step 4: Open the terminal and use the following command: Show dbs - to see all the databases present in your system Use dbs- to use a particular database Show collection- to use a particular collection present in that particular database Find()- to display the data present in the collection Step 5: Enter Exit to get out of the Mongo shell. Never leave the shell open. It gets to hang and your data gets corrupted.

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere