Introduction to POSTMAN for REST API's

  Рет қаралды 40,735

Piyush Garg

Piyush Garg

Жыл бұрын

Hey Everyone, In this video, we will build our own REST API using Node and Express frameworks.
Fake Data API: www.mockaroo.com/
► Complete Full Stack Web Developer RoadMap 2023: • Complete Full Stack We...
► Master NodeJS Playlist: • Master NodeJS
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. It allows developers to run JavaScript on the server side, creating server-side applications with JavaScript.
► My Website: www.piyushgarg.dev
My Gears
► My Girlfriend: amzn.to/3WD6FRp
► Apple MacBook Laptop: amzn.to/3WBJgQn
► Anker USB Hub: amzn.to/3GhZSr0
► Blue Yeti Microphone: amzn.to/3YKZ9FT
► External 27” Monitor: amzn.to/3Vp3xaO
► Logitech MK295 Wireless Keyboard and Mouse: amzn.to/3DuL1bB
► Seagate Expansion 1TB External HDD: amzn.to/3QMm5Q8
► Tripod: amzn.to/3S4OwK4
► Ring Light: amzn.to/3YLf8DR
Disclaimer: All the links above are affiliate links.
Social Links
► Twitter - / piyushgarg_dev
► LinkedIn - / piyushgarg195
Video Titles
What is NodeJS?
What is REST API?
How to design restful API?
REST API Best Practices
Tags
#nodejs #javascript #expressjs #mernstack #developer #api #https #server #javascriptinhindi #webdevelopment #webapp #realtimeapp #serverside #nonblockingio #tech

Пікірлер: 109
@raghavpal4219
@raghavpal4219 Жыл бұрын
The way you simplify things 🔥>>>>
@surajkumar-vd4je
@surajkumar-vd4je Жыл бұрын
"Making difficult concepts easy" is the quality that differentiats Piyush from other trainers
@lakshaysharma8364
@lakshaysharma8364 8 ай бұрын
Bro you are best at teaching .. Continue helping us forever
@poojaganvir5631
@poojaganvir5631 3 ай бұрын
Great explanation , thank you
@sachinandanprasad7618
@sachinandanprasad7618 7 ай бұрын
u'r awosome.......... most underrated play list
@sumirandahal76
@sumirandahal76 2 ай бұрын
thank you sir best teaching
@nishu20501
@nishu20501 19 күн бұрын
both assignments completed finally learnt how to use splice method in array.
@Torpedo91
@Torpedo91 3 ай бұрын
for anybody whose program is not creating new entry in user.json, 1.) Try to console.log() the users after pushing the new entry. 2.) If you see the new entry there, and the code doesn't have syntax mistake then the problem is directory path of user.json copy this code and paste it in the program, const file_path = __dirname + '/users.json'; put this file_path in fs.writefile and try again.
@shrutipawar4794
@shrutipawar4794 Ай бұрын
for me only the new ids are getting added in the data and not the entire user info ...anything you could suggest?
@Torpedo91
@Torpedo91 Ай бұрын
@@shrutipawar4794 did you tried pasting the code in chatgpt?
@weforyouweb1165
@weforyouweb1165 Жыл бұрын
Superb content 🎉
@shubhamtaluja9770
@shubhamtaluja9770 3 ай бұрын
You gained a subscriber, keep up the nice work. :)
@iamakashkumarram
@iamakashkumarram Жыл бұрын
This is called quality content.
@shi-nee7966
@shi-nee7966 Жыл бұрын
amaazinnggglyy explained oofe...💯💥
@technologicalvivek7510
@technologicalvivek7510 2 ай бұрын
Aaj aache se Rest API samajh me aayi meko.Thank you bhaiya .
@sameerfaridi2
@sameerfaridi2 6 ай бұрын
homework done , this is best series of nodeJs
@shubhammali2109
@shubhammali2109 Ай бұрын
You are the greatest of all time, Thank you so much for sharing this gold!
@SulavGhimireeee
@SulavGhimireeee 4 ай бұрын
Thanks bro
@govindkrishnamishra-km8tj
@govindkrishnamishra-km8tj 8 ай бұрын
Thanks a lottt
@Wahab00916
@Wahab00916 2 ай бұрын
love you soo much soo owesome explanation always😍
@anurajrajput4474
@anurajrajput4474 7 ай бұрын
You are simplifying many things and making them freely accessible to a lot of people. No amount of gratitude can truly suffice. 💙🙏🙌
@varunupadhyay2488
@varunupadhyay2488 4 ай бұрын
Have you made Piyush Garg's Node.js notes? I've been through the whole playlist, but my notebook is misplaced. Got an interview in two days, and I'm a bit stuck. Any chance you could share your notes?
@surajkumar-vd4je
@surajkumar-vd4je Жыл бұрын
"Node Js made easy" perfect name for this series.
@jatilyadav4000
@jatilyadav4000 Жыл бұрын
Amazing Video.... Great Explaination... Thank you soo much
@piyushgargdev
@piyushgargdev Жыл бұрын
You are most welcome 😇
@VikasSharma-kc2oc
@VikasSharma-kc2oc Жыл бұрын
🔥🔥
@brosgaming108
@brosgaming108 Жыл бұрын
Another level simplification 🧡
@piyushgargdev
@piyushgargdev Жыл бұрын
Glad you think so! 🚀
@bilalnaeem2985
@bilalnaeem2985 3 ай бұрын
sir ly ❤
@Error404Codes
@Error404Codes Жыл бұрын
lost of love from nepal . you deserve more subscribe . you content is too much good
@sgrdongaming5446
@sgrdongaming5446 Жыл бұрын
lots* 😅
@dishagupta6231
@dishagupta6231 9 ай бұрын
please make a crash course on mern stack
@iamakashkumarram
@iamakashkumarram Жыл бұрын
Awesome teaching style
@piyushgargdev
@piyushgargdev Жыл бұрын
Thanks 😇
@iamakashkumarram
@iamakashkumarram Жыл бұрын
@@piyushgargdev Please MongoDB bhi cover kar dena brother.
@SouravYadav-uf6yk
@SouravYadav-uf6yk Жыл бұрын
First of all I must say awesome teaching.I found you first on Codedman in Redux Toolkit Module then I search in youtube.I completed Codedamn basic nodejs course but things were not clear than I continue your nodejs series.Thanks a lot for this. I Tried Patch Api but index value was undefined then what should i do
@piyushgargdev
@piyushgargdev Жыл бұрын
Hey, First of all, Thanks a lot. Second: I didn't got your doubt, please mention more details
@varunupadhyay2488
@varunupadhyay2488 4 ай бұрын
Have you made Piyush Garg's Node.js notes? I've been through the whole playlist & have made my notes but my notebook is misplaced. Got an interview in two days, and I'm a bit stuck. Any chance you could share your notes?
@khyatichaudhary4083
@khyatichaudhary4083 4 ай бұрын
​Do you need them now​?@@varunupadhyay2488
@hersheynaik3029
@hersheynaik3029 4 ай бұрын
@@varunupadhyay2488 How was your interview?
@user-rn8ix7gp2g
@user-rn8ix7gp2g 23 күн бұрын
guru jiiiiiiii
@iuseitnowone2028
@iuseitnowone2028 7 ай бұрын
so we used fs module to write to the file, but did not use it to read the file.. why?
@malikmubashir2597
@malikmubashir2597 4 ай бұрын
teach everything what you can
@as_if
@as_if Ай бұрын
😭
@mma-dost
@mma-dost Жыл бұрын
👌👍👍👌👌👍
@akankshaa_1210
@akankshaa_1210 28 күн бұрын
hi piyush , my post thing is not working , on the url i am getting can not get /api/user, could you please help
@user-rw5oc3df9k
@user-rw5oc3df9k 4 ай бұрын
not able to delete using fs.unlink but some error
@saubhagyalive3061
@saubhagyalive3061 10 ай бұрын
TypeError: Cannot read properties of undefined (reading 'json') I am getting this error while returning the res.json({status:"success"})
@rishabhraj8233
@rishabhraj8233 4 ай бұрын
patch method: const id = Number(req.params.id); const body = req.body; const user = users.find((user) => user.id === id) const updatedUser = { ...user, ...body }; updatedUser.id=id; users[id-1]=updatedUser fs.writeFile('MOCK_DATA.json', JSON.stringify(users), (err, data) => { return res.json({ status: "Success", updatedUser })})
@siddharthjaiswal9942
@siddharthjaiswal9942 Ай бұрын
purpose of this line? updatedUser.id=id;
@AshishKumar-qt5gs
@AshishKumar-qt5gs Ай бұрын
@@siddharthjaiswal9942 This line ensures that the id of the updated user matches the id extracted from the request URL.
@mayankjain7910
@mayankjain7910 12 күн бұрын
no use
@rdnexta
@rdnexta Ай бұрын
plz sir can you say your vs code theme name. btw, very good video. all not this one.
@rshan7375
@rshan7375 2 ай бұрын
ThunderClient use karne se aur aasan hota
@AMAR-pc6ht
@AMAR-pc6ht 3 ай бұрын
12:35 I got the issue beforehand😅 so removed +1
@user-nz8de4hc6z
@user-nz8de4hc6z 2 ай бұрын
push k andr ...body kyun? dots k bina bhi body likh saqty naaa?
@flopgameryt399
@flopgameryt399 2 ай бұрын
Because id ko khudse dal raha hai hum Without dot kroga toh bi ho jayega push but id nahi aayega So to give id hum spread kr rha hai apna object ko
@karitayade3354
@karitayade3354 10 күн бұрын
doing POST i got error 404 not found
@saranyasingh6847
@saranyasingh6847 Жыл бұрын
for me data of new user is getting updated on localhost:8000/api/users but not in MOCK_DATA.json file in vs code . pls help.
@Ankit-01-01
@Ankit-01-01 7 ай бұрын
fs.writeFile("./MOCK_DATA.json", JSON.stringify(users), (err, data) => { return res.json({ status: "success" }); });
@varunupadhyay2488
@varunupadhyay2488 4 ай бұрын
Have you made Piyush Garg's Node.js notes? I've been through the whole playlist & have made my notes but my notebook is misplaced. Got an interview in two days, and I'm a bit stuck. Any chance you could share your notes?
@user-dz8gx6ke1k
@user-dz8gx6ke1k 3 ай бұрын
after adding multiple users, the mock users.json file is not getting updated. Is this supposed to happen or is my server failing? I can only see the first entry and after that it shows on postman but not in my mock json file
@user-su7eh6yr7k
@user-su7eh6yr7k 3 ай бұрын
// Do This 👍👍 app.post('/api/users', (req, res) => { const body = req.body; users.push({...body, id: users.length + 1}) fs.writeFile('./MOCK_DATA.json', JSON.stringify(users), (err, data) => { return res.json({status: "Success", id: users.length}) }) })
@pratham9987
@pratham9987 3 ай бұрын
@@user-su7eh6yr7k Video mai same code haina ?
@khushijain6993
@khushijain6993 3 ай бұрын
Your video was very helpful! But I've got problem with the patch request I am making. The data I want to update is returned as it is. Its not getting updated. I am giving my code for reference. app.patch('/api/users/:id',(req, res) => { const id = Number (req.params.id) let user = users.find (user => user.id === id) const idx = users.indexOf (user); const newObj = Object.assign (user , req.body) users[idx] = newObj; fs.writeFile ('./MOCK_DATA.json',JSON.stringify(users) , (err,data) => { return res.json ({ status: "success", users: user }) }) }) I am passing raw data in body in postman such as {"job_title": "Data Analyst"} but no updation is happening. Can anyone please help?
@khushijain6993
@khushijain6993 3 ай бұрын
I am unable to go forward in the playlist since my doubt remains uncleared. Thought I would watch this playlist completely... Thankyou for uplaoding good videos.
@itsd2388
@itsd2388 Ай бұрын
@@khushijain6993 same problem i have invested 2 hrs, but still not resolved. Did you get it resolved please tell
@itsd2388
@itsd2388 Ай бұрын
app.use(express.json()); we have to use this middleware finally it ran 😭
@khushijain6993
@khushijain6993 Ай бұрын
@@itsd2388 thankyou for telling 🥲
@surajkharkwal7122
@surajkharkwal7122 7 ай бұрын
sur voice bahut kam ati hai apki
@pkyadav6230
@pkyadav6230 4 ай бұрын
Mere ko to a rhi hai ,Yes he has High pitch
@badalkamli7816
@badalkamli7816 9 ай бұрын
Amazingly explained. Thank you 💙 DELETE request: app.delete("/api/users/:id", (req, res) => { //Get the id of the user const id = Number(req.params.id); //Find out the index of the user with above id from the array "users" const userIdx = users.findIndex((user)=> user.id === id); //Get the deleted user object using splice. Mind we need to get the object and not array as returned by splice method, so '[0]' satisfies this requirement. The resulting object is just for the sake of displaying, you may neglect storing it if you don't want to display. const delUser = users.splice(userIdx, 1)[0]; //Write the changes into the json file. fs.writeFile("./MOCK_DATA.json", JSON.stringify(users), (err, data) => { return res.json({ status: "success", delUser }); }); })
@pavant4391
@pavant4391 3 ай бұрын
thank u for code!! It helps
@madmax180
@madmax180 3 ай бұрын
hey@@pavant4391can you tell me how [0] helps solve this object problem???
@JhaduwaleBhaiya
@JhaduwaleBhaiya 3 ай бұрын
​@@madmax180users.splice contains an array with one object... So that's why we are using [0]
@freelancerpro8408
@freelancerpro8408 26 күн бұрын
Patch Method: .patch((req, res) => { const id = Number(req.params.id); const user = users.find(user => user.id === id); const index = users.indexOf(user) Object.assign(user, req.body) users[index] = user fs.writeFile('./MOCK_DATA.json', JSON.stringify(user), (err, data) => { return res.json({ status: 'Success', data: user }) })
@deeppanchal9567
@deeppanchal9567 9 ай бұрын
Here is a Solution for the Patch request Hope it Helps app.route("/api/users/:id") .patch((req, res) => { // getId stores the Id from the given Parameters in the URL. const getId = Number(req.params.id); // body stores the body in which we've to make changes. const body = req.body; // Finding the user Id from the user array. const userIndex = users.findIndex((user) => user.id === getId); // If we found a user with its Id then gotUser stores that object. const gotUser = users[userIndex]; // Here gotUser has the user Object and body has the changes we have to made. const updatedUser = { ...gotUser, ...body}; // After Merging them, Update the users Array. users[userIndex] = updatedUser; // Lastly, write the changes into the json file. fs.writeFile('./users_mock_data.json', JSON.stringify(users), (err, data) => { return res.json({ status: "Success", updatedUser}); }) })
@user-rw8en1jp4t
@user-rw8en1jp4t 7 ай бұрын
Thanks!, this solution is very readable and clear
@hidev4615
@hidev4615 6 ай бұрын
this can be done using map easily, //you should update this logic: .patch((req, res) => { const id = Number(req.params.id); const { last_name } = req.body; const newUsers = users.map((user) => { if (user.id === id) { return { ...user, last_name }; } else { return user; } }); fs.writeFile('./MOCK_DATA.json', JSON.stringify(newUsers), (err, data) => { return res.json({ status: 'successfully edited user', id }); }); })
@bakchoditank
@bakchoditank 3 ай бұрын
but time complexity is very high if we are using map function@@hidev4615
@JhaduwaleBhaiya
@JhaduwaleBhaiya 3 ай бұрын
​@@hidev4615 will it update the users array??
@lucky-laxmi4799
@lucky-laxmi4799 Ай бұрын
delete method: .delete("/api/users/:id", (req, res) => { const id = Number(req.params.id); const index = users.findIndex((index) => index.id === id); if (index !== -1) { users.splice(index, 1); } return res.json({status: "Successfully Removed"}); })
@SahilThakur-2003
@SahilThakur-2003 17 күн бұрын
alert('chatgpt ????????????????)
@Purvilicious
@Purvilicious Ай бұрын
try these for patch and delete app.patch("/api/users/:id",(req,res)=>{ const id = Number(req.params.id) const body = req.body; console.log(body); const user = users[id-1] users[id-1] = {...user,...body} fs.writeFile("./MOCK_DATA.json", JSON.stringify(users), (err,data)=>{ return res.json({status : "success!"}) }) // return res.json({status : "pending"}); }) app.delete("/api/users/:id",(req,res)=>{ const id = Number(req.params.id) users.splice(id-1,1) fs.writeFile("./MOCK_DATA.json", JSON.stringify(users), (err,data)=>{ return res.json({status : "success!"}) }) // return res.json({status : "pending"}); })
@itsd2388
@itsd2388 Ай бұрын
const id = Number(req.params.id); let user = users.find((user) => user.id === id); if (!user) { return res.status(404).json({ status: "fail" }) } console.log(user); const ind = users.indexOf(user); const body = req.body console.log(body); Object.assign(user, body ); console.log(user); users[ind]=user; fs.writeFile("./MOCK_DATA.json",JSON.stringify(users),(err,data)=>{ return res.json({status: "succuess",data: { user}}) }) it s not updating for patch i have tried everyway
@naitikmodi5895
@naitikmodi5895 5 күн бұрын
.patch((req, res) => { // Edit user with id const id = Number(req.params.id); const body = req.body; const user = users.find((user) => user.id === id); const updatedUser = {...user, ...body}; updatedUser.id = id; users[id-1] = updatedUser fs.writeFile('./MOCK_DATA.json', JSON.stringify(users), (err, data) => { return res.json({ status: "Success", updatedUser})}); }) TRY THIS
@user-de2jj7vl4r
@user-de2jj7vl4r Ай бұрын
.delete((req,res)=>{ //TODO: Delete the user with id const id = Number(req.params.id) if(id!=-1 && users.length>=id){ users.splice(id-1,1); fs.writeFile("./MOCK_DATA.json",JSON.stringify(users),(err,data)=>{ if(!err){ return res.status(200).json({success:"User delete"}); }else{ res.status(500).json({error:"Failed to delete user"}); } }); }else{ return res.status(404).json({error:"User not found"}); } });
@sahaj.arora_
@sahaj.arora_ Ай бұрын
app.delete("/api/users/:id", (req, res) => { let { id } = req.params; //let's delete our user users = users.filter((user) => user.id !== parseInt(id)); //converting users into JSON compatible format users = JSON.stringify(users); //writing into users.json file fs.writeFile("./user_data/users.json", users, (error) => { if (error) { return res.status(500).json({ error: "delete operation failed!" }); } return res.json({ success: "user_details deleted successfully!" }); }); });
Express Middleware
19:50
Piyush Garg
Рет қаралды 53 М.
WebSocket in NodeJS | Socket.IO - Real Time Messaging
32:27
Piyush Garg
Рет қаралды 102 М.
когда одна дома // EVA mash
00:51
EVA mash
Рет қаралды 8 МЛН
Что будет с кроссовком?
00:35
Аришнев
Рет қаралды 2,4 МЛН
1 класс vs 11 класс (рисунок)
00:37
БЕРТ
Рет қаралды 4 МЛН
What is NodeJS?
7:45
Piyush Garg
Рет қаралды 160 М.
Building REST API's using Node and Express.js
20:27
Piyush Garg
Рет қаралды 62 М.
Build ENTIRE Frontends With ONE Prompt - OpenUI Tutorial
8:59
Matthew Berman
Рет қаралды 40 М.
How to make MONEY with OPEN SOURCE?
7:30
Victoria Endless
Рет қаралды 14 М.
What is REST API?
15:41
Piyush Garg
Рет қаралды 52 М.
Build Your Own Cloud Web IDE | Repl.it Clone
1:21:53
Piyush Garg
Рет қаралды 7 М.
What are HTTP Headers in API
17:38
Piyush Garg
Рет қаралды 34 М.
API request and V8 engine | chai aur #javascript
30:34
Chai aur Code
Рет қаралды 88 М.
когда одна дома // EVA mash
00:51
EVA mash
Рет қаралды 8 МЛН