Introduction to POSTMAN for REST API's

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

Пікірлер: 116

  • @surajkumar-vd4je
    @surajkumar-vd4je Жыл бұрын

    "Making difficult concepts easy" is the quality that differentiats Piyush from other trainers

  • @raghavpal4219
    @raghavpal4219 Жыл бұрын

    The way you simplify things 🔥>>>>

  • @rohansingh6329
    @rohansingh6329Ай бұрын

    watched some videos from other youtubers on backend when i was starting was not able to understand from them their teaching was difficult to understand but you made it seem so easy thanks for this playlist i will watch all the videos 👌👌

  • @lakshaysharma8364
    @lakshaysharma836410 ай бұрын

    Bro you are best at teaching .. Continue helping us forever

  • @sachinandanprasad7618
    @sachinandanprasad76189 ай бұрын

    u'r awosome.......... most underrated play list

  • @iamakashkumarram
    @iamakashkumarram Жыл бұрын

    This is called quality content.

  • @shubhamtaluja9770
    @shubhamtaluja97705 ай бұрын

    You gained a subscriber, keep up the nice work. :)

  • @poojaganvir5631
    @poojaganvir56315 ай бұрын

    Great explanation , thank you

  • @technologicalvivek7510
    @technologicalvivek75104 ай бұрын

    Aaj aache se Rest API samajh me aayi meko.Thank you bhaiya .

  • @weforyouweb1165
    @weforyouweb1165 Жыл бұрын

    Superb content 🎉

  • @nishu20501
    @nishu205012 ай бұрын

    both assignments completed finally learnt how to use splice method in array.

  • @namannema3349
    @namannema3349Ай бұрын

    awesome bhaiya thank you got it all

  • @shi-nee7966
    @shi-nee7966 Жыл бұрын

    amaazinnggglyy explained oofe...💯💥

  • @shubhammali2109
    @shubhammali21093 ай бұрын

    You are the greatest of all time, Thank you so much for sharing this gold!

  • @sumirandahal76
    @sumirandahal764 ай бұрын

    thank you sir best teaching

  • @sameerfaridi2
    @sameerfaridi28 ай бұрын

    homework done , this is best series of nodeJs

  • @Wahab00916
    @Wahab009163 ай бұрын

    love you soo much soo owesome explanation always😍

  • @anurajrajput4474
    @anurajrajput44749 ай бұрын

    You are simplifying many things and making them freely accessible to a lot of people. No amount of gratitude can truly suffice. 💙🙏🙌

  • @varunupadhyay2488

    @varunupadhyay2488

    6 ай бұрын

    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?

  • @yashmehta9953
    @yashmehta995317 күн бұрын

    Also you can use thunder client instead of postman. It is an extension of vs code

  • @govindkrishnamishra-km8tj
    @govindkrishnamishra-km8tj10 ай бұрын

    Thanks a lottt

  • @brosgaming108
    @brosgaming108 Жыл бұрын

    Another level simplification 🧡

  • @piyushgargdev

    @piyushgargdev

    Жыл бұрын

    Glad you think so! 🚀

  • @malikmubashir2597
    @malikmubashir25976 ай бұрын

    teach everything what you can

  • @as_if

    @as_if

    3 ай бұрын

    😭

  • @jatilyadav4000
    @jatilyadav4000 Жыл бұрын

    Amazing Video.... Great Explaination... Thank you soo much

  • @piyushgargdev

    @piyushgargdev

    Жыл бұрын

    You are most welcome 😇

  • @user-tk2rb5xp1i
    @user-tk2rb5xp1i6 күн бұрын

    Good One

  • @SulavGhimireeee
    @SulavGhimireeee6 ай бұрын

    Thanks bro

  • @surajkumar-vd4je
    @surajkumar-vd4je Жыл бұрын

    "Node Js made easy" perfect name for this series.

  • @Error404Codes
    @Error404Codes Жыл бұрын

    lost of love from nepal . you deserve more subscribe . you content is too much good

  • @sgrdongaming5446

    @sgrdongaming5446

    Жыл бұрын

    lots* 😅

  • @tusharsingh1915
    @tusharsingh19154 күн бұрын

    To all the people installing postman on their system, Now Postman is also available as a extension in vscode, So i think their is no need to switch a tab and you are good to go:)

  • @ArunKumar_237
    @ArunKumar_2372 күн бұрын

    super

  • @VikasSharma-kc2oc
    @VikasSharma-kc2oc Жыл бұрын

    🔥🔥

  • @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

    6 ай бұрын

    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

    6 ай бұрын

    ​Do you need them now​?@@varunupadhyay2488

  • @hersheynaik3029

    @hersheynaik3029

    6 ай бұрын

    @@varunupadhyay2488 How was your interview?

  • @bilalnaeem2985
    @bilalnaeem29855 ай бұрын

    sir ly ❤

  • @vivekprajapati5463
    @vivekprajapati546313 күн бұрын

    Kindly make a playlist of api

  • @iamakashkumarram
    @iamakashkumarram Жыл бұрын

    Awesome teaching style

  • @piyushgargdev

    @piyushgargdev

    Жыл бұрын

    Thanks 😇

  • @iamakashkumarram

    @iamakashkumarram

    Жыл бұрын

    @@piyushgargdev Please MongoDB bhi cover kar dena brother.

  • @stewie__69
    @stewie__6912 күн бұрын

    Thunder client, a vs code extension is the best alternative to Postman.

  • @user-rn8ix7gp2g
    @user-rn8ix7gp2g2 ай бұрын

    guru jiiiiiiii

  • @dishagupta6231
    @dishagupta623111 ай бұрын

    please make a crash course on mern stack

  • @mma-dost
    @mma-dost Жыл бұрын

    👌👍👍👌👌👍

  • @iuseitnowone2028
    @iuseitnowone20289 ай бұрын

    so we used fs module to write to the file, but did not use it to read the file.. why?

  • @ketanjadhav4328
    @ketanjadhav432820 күн бұрын

    Which theme you are using ?

  • @Torpedo91
    @Torpedo915 ай бұрын

    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

    3 ай бұрын

    for me only the new ids are getting added in the data and not the entire user info ...anything you could suggest?

  • @Torpedo91

    @Torpedo91

    3 ай бұрын

    @@shrutipawar4794 did you tried pasting the code in chatgpt?

  • @mayanksinha1883

    @mayanksinha1883

    Ай бұрын

    @@shrutipawar4794 had the same problem make sure selecting body in postman while filling the data

  • @rdnexta
    @rdnexta2 ай бұрын

    plz sir can you say your vs code theme name. btw, very good video. all not this one.

  • @user-rw5oc3df9k
    @user-rw5oc3df9k6 ай бұрын

    not able to delete using fs.unlink but some error

  • @akankshaa_1210
    @akankshaa_12102 ай бұрын

    hi piyush , my post thing is not working , on the url i am getting can not get /api/user, could you please help

  • @rshan7375
    @rshan73754 ай бұрын

    ThunderClient use karne se aur aasan hota

  • @AMAR-pc6ht
    @AMAR-pc6ht5 ай бұрын

    12:35 I got the issue beforehand😅 so removed +1

  • @RAVIKUMAR-md3vk
    @RAVIKUMAR-md3vk9 күн бұрын

    kos ->king of simplifier

  • @tusharsingh1915
    @tusharsingh19154 күн бұрын

    Abb lgg rha hai..backend padh rha hu👌🥲

  • @saubhagyalive3061
    @saubhagyalive3061 Жыл бұрын

    TypeError: Cannot read properties of undefined (reading 'json') I am getting this error while returning the res.json({status:"success"})

  • @user-ft1kl4xq4u

    @user-ft1kl4xq4u

    Ай бұрын

    instead of res.json({status:"success"}) use res.send({status:"success"})

  • @user-nz8de4hc6z
    @user-nz8de4hc6z4 ай бұрын

    push k andr ...body kyun? dots k bina bhi body likh saqty naaa?

  • @flopgameryt399

    @flopgameryt399

    4 ай бұрын

    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

  • @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

    9 ай бұрын

    fs.writeFile("./MOCK_DATA.json", JSON.stringify(users), (err, data) => { return res.json({ status: "success" }); });

  • @varunupadhyay2488

    @varunupadhyay2488

    6 ай бұрын

    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-dz8gx6ke1k5 ай бұрын

    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

    5 ай бұрын

    // 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

    5 ай бұрын

    @@user-su7eh6yr7k Video mai same code haina ?

  • @karitayade3354
    @karitayade33542 ай бұрын

    doing POST i got error 404 not found

  • @khushijain6993
    @khushijain69935 ай бұрын

    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

    4 ай бұрын

    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

    3 ай бұрын

    @@khushijain6993 same problem i have invested 2 hrs, but still not resolved. Did you get it resolved please tell

  • @itsd2388

    @itsd2388

    3 ай бұрын

    app.use(express.json()); we have to use this middleware finally it ran 😭

  • @khushijain6993

    @khushijain6993

    3 ай бұрын

    @@itsd2388 thankyou for telling 🥲

  • @surajkharkwal7122
    @surajkharkwal71229 ай бұрын

    sur voice bahut kam ati hai apki

  • @pkyadav6230

    @pkyadav6230

    6 ай бұрын

    Mere ko to a rhi hai ,Yes he has High pitch

  • @rishabhraj8233
    @rishabhraj82336 ай бұрын

    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

    3 ай бұрын

    purpose of this line? updatedUser.id=id;

  • @AshishKumar-qt5gs

    @AshishKumar-qt5gs

    3 ай бұрын

    @@siddharthjaiswal9942 This line ensures that the id of the updated user matches the id extracted from the request URL.

  • @mayankjain7910

    @mayankjain7910

    2 ай бұрын

    no use

  • @badalkamli7816
    @badalkamli781611 ай бұрын

    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

    5 ай бұрын

    thank u for code!! It helps

  • @madmax180

    @madmax180

    5 ай бұрын

    hey@@pavant4391can you tell me how [0] helps solve this object problem???

  • @Ayush37262

    @Ayush37262

    5 ай бұрын

    ​@@madmax180users.splice contains an array with one object... So that's why we are using [0]

  • @rishabhkedia9304

    @rishabhkedia9304

    12 күн бұрын

    After this there must be a change in POST as well, as new user being created will have glitch in ID, if any middle element is deleted from array. as POST included users.length + 1 as new userID

  • @darkknight-rp2ry
    @darkknight-rp2ryАй бұрын

    🫡🫡🫡🇮🇳❤️

  • @itsd2388
    @itsd23883 ай бұрын

    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

  • @lucky-laxmi4799
    @lucky-laxmi47993 ай бұрын

    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

    2 ай бұрын

    alert('chatgpt ????????????????)

  • @deeppanchal9567
    @deeppanchal956711 ай бұрын

    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

    8 ай бұрын

    Thanks!, this solution is very readable and clear

  • @hidev4615

    @hidev4615

    8 ай бұрын

    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

    5 ай бұрын

    but time complexity is very high if we are using map function@@hidev4615

  • @Ayush37262

    @Ayush37262

    5 ай бұрын

    ​@@hidev4615 will it update the users array??

  • @user-de2jj7vl4r
    @user-de2jj7vl4r3 ай бұрын

    .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_3 ай бұрын

    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!" }); }); });