Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

Full stack web development Course | 117. Swag Shop API: Fetching Products

4.8K views on YouTube

Full-stack web development Tutorial in Just 3 Weeks

Week 3: Day 2
Section 12: Intro to Node, Mongo, & REST APIs
Tutorial 117: Swag Shop API: Fetching Products

LECTURE CONTENT:
00:00:00 Introduction
00:01:29 Creating a Get request
00:06:45 Checking the Get request on POSTMAN
00:09:40 End

In this video tutorial, we are going to learn to fetch data from the shell using Get request.
Step 1: app.get(‘/product’, function (request,response){}
get is an HTTP method for which the middleware function applies/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

Step 2: write the message to be displayed in case of any error. Display “could not fetch product”, if there is failure else ” product” in case of success.
Step 3: Check the Get request in POSTMAN
Step 4: Check the Get request in the mongo shell using the find() method.