Build A Restful Api With Node.js Express & MongoDB | Rest Api Tutorial

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • Check out my courses and become more creative!
    developedbyed....
    ❤Become a patreon for exclusive videos and more!
    / dev_ed
    Microphones I Use
    Audio-Technica AT2020 - geni.us/Re78 (Amazon)
    Deity V-Mic D3 Pro - geni.us/y0HjQbz (Amazon)
    BEHRINGER Audio Interface - geni.us/AcbCpd9 (Amazon)
    Camera Gear
    Fujifilm X-T3 - geni.us/7IM1 (Amazon)
    Fujinon XF18-55mmF2.8-4 - geni.us/sztaN (Amazon)
    PC Specs
    Kingston SQ500S37/480G 480GB - geni.us/s7HWm (Amazon)
    Gigabyte GeForce RTX 2070 - geni.us/uRw71gN (Amazon)
    AMD Ryzen 7 2700X - geni.us/NaBSC (Amazon)
    Corsair Vengeance LPX 16GB - geni.us/JDqK1KK (Amazon)
    ASRock B450M PRO4 - geni.us/YAtI (Amazon)
    DeepCool ATX Mid Tower - geni.us/U8xJY (Amazon)
    Dell Ultrasharp U2718Q 27-Inch 4K - geni.us/kXHE (Amazon)
    Dell Ultra Sharp LED-Lit Monitor 25 2k - geni.us/bilekX (Amazon)
    Logitech G305 - geni.us/PIjyn (Amazon)
    Logitech MX Keys Advanced - geni.us/YBsCVX0 (Amazon)
    DISCLAIMERS:
    I am a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.
    Twitter: / deved94
    Instagram: / developedbyed
    Github: github.com/Dev...
    We are going to cover how to create a restful api using node.js express and mongodb together with mongoose.
    Rest apis help us decouple our backend code from our front end so we can use it across multiple application (mobile apps, web apps, etc).
    We are going to learn how to build a simple blog post type api with all the useful methods(GET,POST,DELETE,PATCH).
    We use Node.js as our backend language, express.js is going to help us create routes easier and middlewares and we use mongodb together with mongoose to create schemas and models that define how our data looks.
    If you are a beginner with nodejs, express or mongodb I hope that this tutorial will give you a good idea of how these technologies work well together.
    🎵 Music:
    Outro:
    LAKEY INSPIRED - Me 2 (Feat. Julian Avila)
    Music By: / lakeyinspired
    Intro:
    Dj Quads
    Track Name: "Every Morning"
    Music By: Dj Quads @ / aka-dj-quads
    Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
    creativecommons....
    #mongodb #nodejs #express.js
  • Наука та технологія

КОМЕНТАРІ • 1,6 тис.

  • @samadabbas4628
    @samadabbas4628 Рік тому +38

    For people visiting this tutorial recently, some important things to note:
    1. MLAB is not in function anymore you have to use mongodb atlas.
    2. the cluster by default will not allow write access so you have to set it up in settings.
    3. At 44:00, remove function is deprecated so you have to use deleteOne function

    • @sirikamkanampati1112
      @sirikamkanampati1112 Рік тому

      Can you tell where we have to change the access exactly?

    • @valerio9851
      @valerio9851 Рік тому

      thank you so much! I was like wtf is going on? ahahahaha thanks a lot

    • @ngantukASMR
      @ngantukASMR 7 місяців тому

      Also id recommend using express.json() as a middleware instead of using body parser, since its built in

  • @TechnicalStudio
    @TechnicalStudio 4 роки тому +239

    I loved your teaching style 😍😍.. Keep it up.. It helps us a lot

    • @egesaglam9500
      @egesaglam9500 3 роки тому

      @Nikolas Ryker i have another scammers thanks alot

  • @Shinoku911
    @Shinoku911 5 років тому +355

    Please don't stop with this tutorials!! Super awesome for beginners like me.

    • @BekBrace
      @BekBrace 4 роки тому +11

      Good luck friend, although I do not think that this specific tutorial is for beginners because if you already know about these techs then you're not a beginner anymore :)

  • @iqrasuhail3516
    @iqrasuhail3516 3 роки тому +109

    I’m a student studying CS at Ball State University, IN. I am not someone who would comment on a video on youtube because she likes it. This is legit the first time ONLY to tell you that nobody explains it better. All your videos, be it explaining hooks in React, cool animations or CSS, or this tutorial - they are all explained so well! Thank you for your content.

  • @developedbyed
    @developedbyed  5 років тому +282

    Finally 1080p jesus...

    • @thanveershah4758
      @thanveershah4758 5 років тому +3

      @Jack Rong Nop , I don't think we need that

    • @kelvinmunene4750
      @kelvinmunene4750 5 років тому

      Nice videos.
      Kindly, do a video on MERN

    • @Oshchenkov
      @Oshchenkov 5 років тому +1

      When you init npm add flag -y for standart settings ( npm init -y )

    • @arif.wijianto
      @arif.wijianto 5 років тому

      awesome thanks you ed

    • @razx2009
      @razx2009 4 роки тому

      Just a quick question can we read data from already existing collection in mongo without creating schema?

  • @CodeDreamer68
    @CodeDreamer68 3 роки тому +2

    Since Express 4.16.0, bodyParser is built-in.
    ```
    const express = require("express");
    const app = express();
    app.use(express.json());
    app.use(
    express.urlencoded({
    extended: true,
    })
    );
    ```

  • @developedbyed
    @developedbyed  5 років тому +91

    Magic!

    • @daniyelme9535
      @daniyelme9535 4 роки тому

      Hi Ed, what happened to your Github account? Thanks for the great content!

    • @whiteblackbox
      @whiteblackbox 3 роки тому

      i finally knew your trick after slow it down on 0.25 speed :)

  • @codergeany5861
    @codergeany5861 4 роки тому +46

    Finally found a developer with humor , nice tutorial man

  • @jasonennis4905
    @jasonennis4905 5 років тому +179

    Let me guess the one dislike on this video is a PHP developer.

    • @peefg
      @peefg 5 років тому +10

      😕 I don't think so.. I am PHP developer, but I have always wanted to start with something like this. This guy is a hero for me. I have immediately subscribed and liked this video. I wish he had zero dislikes.

    • @ajricherson1099
      @ajricherson1099 4 роки тому +4

      Php devs don't love themselves

    • @RadosBudisa
      @RadosBudisa 4 роки тому +2

      @@ajricherson1099 We don't love our selfs but we are selfless!

    • @oyoyoyoyoyoy9479
      @oyoyoyoyoyoy9479 4 роки тому +9

      @@peefg no, probably thats Java guys

    • @__sagar_shah__591
      @__sagar_shah__591 4 роки тому +1

      wow that's not sarcastic at all!!!!

  • @Assassin_Duck
    @Assassin_Duck 4 роки тому +2

    When I try to save the first post to the database it never executes the .save() callback, and I have exactly the same code as Ed. Anyone have any ideas?

    • @harpreet2111
      @harpreet2111 4 роки тому

      I am facing the same issue. Were you able to resolve it?

    • @Assassin_Duck
      @Assassin_Duck 4 роки тому

      @@harpreet2111 Sort of, I had to make the functions async. That made them work

    • @harpreet2111
      @harpreet2111 4 роки тому +1

      @@Assassin_Duck ok.. Thanks for the reply!. I just whitelisted all the IP's in Atlas and it worked for me.

    • @aamirjamal6833
      @aamirjamal6833 4 роки тому +1

      @@harpreet2111 Thanks, this helped me.

  • @huangehe8306
    @huangehe8306 5 років тому +75

    I think that it will be cool if U make tutorial for authorization (registration, login) app with some other features (for example,using React for front), and show how to integrate that with backend. Thank u for great explaining.

    • @janzmarfz373
      @janzmarfz373 4 роки тому

      up for this or btw angularjs

    • @SivaNare
      @SivaNare 4 роки тому

      guys can some one share working code please (github) devE's link for github in description doesent exist i am having issue writing data to database but i am not getting any errors couldn't figure out trying very hard

    • @ege2026
      @ege2026 3 роки тому +1

      @@SivaNare did you find it? i post data from postman but it gives an empty error message while it's not responding the data back.

    • @GTX-cr4ob
      @GTX-cr4ob 2 роки тому

      @@ege2026 i can help

  • @a.anvarbekov
    @a.anvarbekov 3 роки тому +2

    29:00 app.use(express.json()) this can solve that problem, no need to install body-parser. BTW, great tutorial
    edited: sorry I didn't try to sound clever, I didn't know the time when u did this tutorial the above method wasn't available

  • @Hari2897
    @Hari2897 4 роки тому +8

    I'm following along the tutorial but Postman is stuck at "Sending" @ 34:12
    It prints console log message but nothing with mongoDB... I see nothing nothing updated in MongoDB atlas too.
    Please reply as to what could the solution to the problem be?

    • @mdhishaamakhtar2040
      @mdhishaamakhtar2040 4 роки тому +1

      Same

    • @n_arin
      @n_arin 4 роки тому

      Check your DB connection string

    • @ChrisPChickennn
      @ChrisPChickennn 4 роки тому +1

      same problem. I tried retrieving the connection string again, no luck. seems to be a problem with the promise, or postman not working with the db. my postman console log shows Error: socket hang up on the post requests im sending after they fail - looked online for context/resolution, not much help.. only thing i could find that might help is about making sure the proxy is configured correctly. thats outside my wheelhouse, i just made sure to turn off any proxy in postman via settings>proxy, still no luck.

    • @chinkx1998
      @chinkx1998 4 роки тому +1

      Hi. I am facing the same issue. Do u guys able to find a solution?

    • @walljacket
      @walljacket 4 роки тому

      I had the same issue. It took me hours to catch the issue.. I spelled mongoose with a capitial "M" as in const mongoose = require('Mongoose') thus all of my db operations timed out.

  • @Maxonepiece
    @Maxonepiece 4 роки тому +2

    Love this tutorial! Though, I'm stuck at the postman : POST (34:00)
    It seems that since mlab switched to atlas mango db, the server connection is way slower (proper 2 minutes) (or I did something wrong setting it up lol) - hence the postman just gives up on the request. I don't really know what to do, would love some guidance here

    • @Afghanistanmujaheed1234
      @Afghanistanmujaheed1234 4 роки тому

      bro use mongodb atlas...The whole process is same just made it with atlas

    • @Maxonepiece
      @Maxonepiece 4 роки тому

      Captain Macintosh Pubg alright safe ! Is your database connecting fast ? I’ll try again

    • @Maxonepiece
      @Maxonepiece 4 роки тому +1

      Deffo not working, I get a « could not get any response » from postman

    • @Afghanistanmujaheed1234
      @Afghanistanmujaheed1234 4 роки тому

      @@Maxonepiece mine works fast

    • @aamirjamal6833
      @aamirjamal6833 4 роки тому +1

      I have the same issue.. tried debugging, gets stuck in post.save() in posts.js.. let me know if you or anybody knows the fix

  • @11am
    @11am 5 років тому +28

    I really love people that teach code with character, it's so much engaging than being stiff and plain, thank you! Also you can use Yarn instead of npm haha

  • @Scapben
    @Scapben 3 роки тому +5

    somehow this syntax at 29:13 worked for Ed but not for me...
    router.post("/", (req, res) => {
    console.log(req.body);
    });
    ...when sending a POST request with Postman, I could not get any response
    SOLUTION:
    router.post("/", (req, res) => {
    res.send(console.log(req.body));
    });
    INSTEAD OF
    router.post("/", (req, res) => {
    console.log(req.body);
    });
    I have no idea what I'm doing but this worked for me !

    • @kristboshnjaku135
      @kristboshnjaku135 3 роки тому

      did you manage to find the solution to this? im having the same issue.. :(

    • @ayeshashabbir2097
      @ayeshashabbir2097 3 роки тому +1

      facing same issue.. i am just getting:
      {
      "message": {}
      }

    • @Scapben
      @Scapben 3 роки тому

      ​ @Krist Boshnjaku and @Ayesha Shabbir
      Did you try
      res.send(console.log(req.body));
      INSTEAD OF
      console.log(req.body); ?
      That worked for me three months ago.

    • @ayeshashabbir2097
      @ayeshashabbir2097 3 роки тому

      Yes I tried res.send at first but it didn't work ..so just for checking I changed it to console.log to see whats happening.

    • @ayeshashabbir2097
      @ayeshashabbir2097 3 роки тому

      @@Scapben i'll check it again!!

  • @jaydesai1430
    @jaydesai1430 3 роки тому +7

    Hey I'm getting error on the time interval of 33:47 to 35:54
    were there is new (first) data generate for the mongoose with post. For me its just going into the ".catch" instead of the ".then"

    • @kristboshnjaku135
      @kristboshnjaku135 3 роки тому

      did you manage to find the solution to this? im having the same issue.. :(

    • @jaydesai1430
      @jaydesai1430 3 роки тому

      @@kristboshnjaku135
      try {
      const savedPosted = await post.save();
      res.json(savedPosted);
      }catch(err) {
      res.json({ message: err });
      }

    • @jaydesai1430
      @jaydesai1430 3 роки тому +1

      @@kristboshnjaku135 Try this out and also one more thing make sure you have your ip address connected to the altas mongo db because when you run on localhost it won't with just db user and password you will need to config the ip address.

    • @jaydesai1430
      @jaydesai1430 3 роки тому +1

      @@kristboshnjaku135 These 2 thing resolved my issue.

    • @LIFE-nr1yg
      @LIFE-nr1yg 3 роки тому

      @@jaydesai1430 hi Jay, sorry to say but this didn't help; still catching the error not the post itself in Postman.

  • @santiagowhite5467
    @santiagowhite5467 3 роки тому +4

    When I post, the json file comes only with message={} , and it doesnt post anything to mongodb atlas. Help

    • @kristboshnjaku135
      @kristboshnjaku135 3 роки тому

      did you manage to find the solution to this? im having the same issue.. :(

    • @santiagowhite5467
      @santiagowhite5467 3 роки тому

      @@kristboshnjaku135 I manage to fix it:
      const express = require('express');
      const router = express.Router();
      const Film = require('../models/Film');
      router.get('/', (req, res) => {
      console.log("We are on films GET");
      res.send('We are on films GET');
      });
      router.post('/', (req,res) => {
      console.log("We are on films POST");
      console.log(req.body);
      res.send('We are on films POST');
      });
      module.exports = router;
      just edit films to whatever u want

    • @kristboshnjaku135
      @kristboshnjaku135 3 роки тому

      @@santiagowhite5467 You managed to run the code and get the console.log work, but did you actually manage to insert your data to the db? that's the problem here...

    • @santiagowhite5467
      @santiagowhite5467 3 роки тому +1

      @@kristboshnjaku135 I did, I suggest you watch a more recent video by Dev Ed in which he uses mongodb atlas, where he takes all steps necessary to ensure connectivity with db. The name of the video is “build a nodejs api authentication (...)”. He builds a rest api aswell.

    • @kristboshnjaku135
      @kristboshnjaku135 3 роки тому +1

      @@santiagowhite5467 Ok, I'll give it a try... I'm still confused why it's just catching the error instead of the data first :p At least I can get it working..
      Much appreciated bud!

  • @AlejandroLZuvic
    @AlejandroLZuvic 4 роки тому +12

    "Good job package.json, you're doing your job!"
    I spat my coffee laughing LOL

  • @doubledave22
    @doubledave22 4 роки тому +1

    at 34:16 when i send the post, postman times out and gives warning "Warning: This request did not get sent completely and might not have all the required system headers". I followed the postman recommended fixes and nothing. I can view the post on "get" but i cant seem to post. Any ideas?

  • @liers2563
    @liers2563 5 років тому +6

    Hi, I'm having problem with postman. Its returning me "could not get any response" when posting "my first post" but prior to that it is showing in the terminal. What could be wrong?

    • @surajitsil1996
      @surajitsil1996 4 роки тому

      I'm having it too, did you solved it?
      then kindly tell me the solution.

    • @kristboshnjaku135
      @kristboshnjaku135 3 роки тому

      did you manage to find the solution to this? im having the same issue.. :(

  • @Hydrush
    @Hydrush Рік тому +2

    Thank you so much buddy, Only left to learn for me was backend and you made it so easy. Now i can move on to my journey on becoming a full stack developer on flutter lessgo .. Love you man.

  • @kaanuki3203
    @kaanuki3203 5 років тому +17

    Ive watched many Node, Express tutorials. This is, by far, the best one Ive seen. Thank you!

    • @blazi_0
      @blazi_0 3 роки тому

      hi i hope u can help me
      why middlewares not working ?
      app.use not working for me

  • @mikealejandro3938
    @mikealejandro3938 3 роки тому +2

    If you are watching in 2021, you have to use mongoDB Atlas, it's the same process, jus create your account and create a database, then in the section clusters you have an interface, just click in coneection and click in conecct aplication, and they will give you a link and you can keep the process with ed, it's just the same
    And about creating an user, just go to the section database access and create your user
    And if you have a problem in the connection stuff, just copy this right after the data base variable
    {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    dbName: "Rest-Api-Tutorial"
    }
    And put whatever name you want to put !
    And sorry for my poor english, and have a good day working !

  • @shubhammukherjee6845
    @shubhammukherjee6845 5 років тому +5

    Hey man, I need help. I am totally new to Express+Mongo, I have done exactly what you have showed. Its getting connected to database too. But when I am trying to post(save) data to database, its not showing any result( res.json(data) is not coming up in postman). What I think is happening is I have not mentioned the collection name. Do we need to specify the collection name too in Schema. if yes, could you please provide me with full details. Thanks in advance

    • @chanellesesh4977
      @chanellesesh4977 5 років тому

      Did you manage to fix this??

    • @shubhammukherjee6845
      @shubhammukherjee6845 5 років тому

      @@chanellesesh4977 yes. We need to pass the collection name as a parameter if the collection is already created in the database. In my case, I wanted to use one of the collection already provided in Mongo Db Atlas. So I just pass the name of the collection as a parameter in the Schema. That's it.

    • @shubhammukherjee6845
      @shubhammukherjee6845 5 років тому +2

      @ yeah sure
      const GradesSchema = mongoose.Schema({
      recrd : {
      type : String
      },
      vesslterms : {
      type : String
      },
      feature_type :{
      type : String
      },
      chart :{
      type : String
      },
      latdec :{
      type : Number
      },
      londec :{
      type : Number
      },
      gp_quality :{
      type : String
      },
      depth :{
      type : String
      },
      sounding_type :{
      type : String
      },
      history :{
      type : String
      },
      quasou : {
      type : String
      },
      watlev: {
      type : String
      }
      }, {collection : 'shipwrecks'});
      The 'shipwrecks' being the collection name.

    • @shubhammukherjee6845
      @shubhammukherjee6845 5 років тому

      @ are you giving the right database name in the connection url? Change the 'test' part with your database name in the connection url

    • @StephenSimon
      @StephenSimon 3 роки тому +1

      { useNewUrlParser: true, useUnifiedTopology: true }, add this to your app.js file inside mongoose.connect

  • @programming5835
    @programming5835 2 роки тому +1

    best course to learn about node js for beginners . Don't search for any other course just continue his technique it's worth a time.

  • @dragonballsuper1519
    @dragonballsuper1519 4 роки тому +21

    You are a really good teacher. You don´t just code away but actually take your time to explain what´s happening with each line of code. It makes it so much easier to understand!
    Subbed.

  • @thedigs8563
    @thedigs8563 3 роки тому +2

    Got an error trying to create a post document, i console logged the whole thing:
    MongooseError: Operation `posts.insertOne()` buffering timed out after 10000ms
    at Timeout. (C:\Users\thedi\Documents\Coding
    est-api
    ode_modules\mongoose\lib\drivers
    ode-mongodb-native\collection.js:185:20)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
    Can anyone help me with this?

  • @lemuelreyes1941
    @lemuelreyes1941 4 роки тому +8

    Spent all day looking for someone to teach it in an understandable way, this ended my search. Thank you!

  • @anshumanp74
    @anshumanp74 3 роки тому +2

    for those who are getting error or say the /posts is not loading then just write
    // Middlewares
    app.use('/posts', (req, res, next) => {
    console.log("hello this is a posts middleware");
    next()
    });
    the next function removes the discontinuation to the get handlers which are below the app.use middleware

    • @shivanigaddagimath2143
      @shivanigaddagimath2143 3 роки тому

      Hey Anshuman, thanks for that tip! have you completed many projects in node? Are you a 2021-passout and open to opportunities in web development currently?

  • @dean6046
    @dean6046 4 роки тому +8

    First time viewer here. Love the energy, passion and light hearted humor. Keep up the good work! I believe I got here from Brad Traversy recommending your channel.

  • @codr6934
    @codr6934 4 роки тому +2

    Hello Ed, i have a connection to the database, but when i click on send (in postman) nothing happens in my mongodb database and i dont get a response in postman. its just still waiting. (min 34). until here everything worked fine!
    I am using mongodb, because mlab doesent allow new registrations and i took the option (connect your application to your cluster using mongodb drivers)
    What can i do?
    ps: very good tutorial, you have my subscribe

    • @codr6934
      @codr6934 4 роки тому

      fixed it: i took the 2. option (usind drivers) and took version 3, copy pasted the link and did it without any download stuff, just using the link and env

  • @noeljose
    @noeljose 3 роки тому +15

    Honestly, I spend 53 minutes and 54 seconds of my life learning something useful. Thank you, Ed. You will have a good love life.

  • @henrychew9177
    @henrychew9177 3 роки тому +2

    Not sure if anyone will even see this but MongoDB didn't like using a Google Cloud server-I would get "buffering timed out after 10000ms" after Posting. Switching to AWS seemed to solve the issue though.
    Also @ 33:42 res.json ( { message:err } ),
    it seemed that it should be res.json ( { message:err.message } ) instead.

    • @saptarshihore3388
      @saptarshihore3388 3 роки тому

      iam already on AWS, but still iam getting the same error

    • @henrychew9177
      @henrychew9177 3 роки тому

      @@saptarshihore3388 try switching server locations?

  • @nirav10011101
    @nirav10011101 5 років тому +4

    This one is cool tutorial. To the point.
    Btw, mlab has been acquired by Mongo atlas. So, everything has been changed

    • @maniiakas
      @maniiakas 4 роки тому

      Not really, Mongo atlas is almost identical and it is very easy to go along with the tutorial

  • @omarramos1985
    @omarramos1985 3 роки тому +1

    -For the error after Posting in the minute 33:42:
    THE SOLUTION is rewriting your code this way in the moongose connection using ".then()" and ".catch" after ".connect()":
    mongoose
    .connect(process.env.MONGO_PROD_URI, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true, })
    .then(() => console.log("Database connected!"))
    .catch(err => console.log(err));

  • @yayz_
    @yayz_ 3 роки тому +3

    10:40 "It says to connect use driver blah blah blah blah here" ... This is pretty much how I read documentation..

  • @sagara5982
    @sagara5982 4 роки тому +1

    I'm getting an error named post.save(..).then(..).catch() is not a function can you help me out with this plzzz

  • @abdullahakram4942
    @abdullahakram4942 4 роки тому +6

    1 Year later still the best tutorial. Just started NodeJs and this covered mostly all the concepts i needed to build an API. Keep up the good work!!

    • @JagathVM
      @JagathVM 2 місяці тому

      5 years later, still the best tutorial :)

  • @marcofabiopavone5027
    @marcofabiopavone5027 2 роки тому +1

    I failed at 36:23, I got an empty error message. I guess the problem is with connection, as of June 2022 there's no mlab anymore, so connection string looks a little bit different. Can you make tutorial how to connect with mongoDB selecting "Connect your application" option?

  • @pockit_fluff
    @pockit_fluff 4 роки тому +5

    For people having trouble around the 33:00 minute mark when trying to commit a post via Postman I suggest checking your name and password is correct on your mongoDB link.

    • @kiranmahajan778
      @kiranmahajan778 4 роки тому +3

      Its totally correct but still not working

    • @joseheliojunior242
      @joseheliojunior242 4 роки тому

      U are right man. It´s a big confusing, but I got it
      Thanks.

    • @robertoradu9965
      @robertoradu9965 4 роки тому

      @@kiranmahajan778 Have you solved ? Commit (save method) is not working and no error message is displayed!

    • @robertoradu9965
      @robertoradu9965 4 роки тому +1

      here the solution: check if your ip changed, update your whitelist in the mlab, then it should work

    • @kiranmahajan778
      @kiranmahajan778 4 роки тому

      @@robertoradu9965 okay i will try!

  • @harishs7384
    @harishs7384 2 роки тому +1

    there's a lot of using "POST" ....i only understood after several attempts.....please make use of other relative terms instead of using the "POST".....a bit difficult for newbie....but though its a pretty good lecture

  • @christian15213
    @christian15213 4 роки тому +8

    YOOOOO lol you made me laugh so hard when you were like "I don't know why you would have a price." The way you gave attention to that was just awesome. "let me get rid of that." OMG laughing so hard.

  • @AowTingy
    @AowTingy 2 роки тому +1

    Please make updated restful app tutorial. Because moab is down and i like to follow everything but now there confusion on 20:00 of the video cuz i cant access localhost:3000/posts
    So please updated version

  • @guido2333
    @guido2333 5 років тому +17

    This is awesome! well explained, easy to understand and great tempo!

  • @justinherrera6790
    @justinherrera6790 4 роки тому +1

    mLab is now part of the MongoDB family, the configuration seems very different from now. To configure a cluster and connection config, you can check here www.mongodb.com/blog/post/quick-start-nodejs-mongodb--how-to-get-connected-to-your-database

  • @Vt12365
    @Vt12365 4 роки тому +6

    Thank you for making this, most tutorials I come across are difficult to understand or way too slow. Your pace and explanations for this tutorial is perfect. It is exactly what I was looking for.

  • @robinr2336
    @robinr2336 3 роки тому +1

    NOTE: @35:37 res.json(savedPost) will throw an error,
    you are passing an object...
    change to: res.json( { savedPost } ).

  • @daniellaerachannel
    @daniellaerachannel 5 років тому +5

    use mongodb atlas instead of mlab, cause is has been acquired, great tutorial

    • @kenyadorcelus917
      @kenyadorcelus917 5 років тому

      By MongoDB

    • @GaurangDhorda
      @GaurangDhorda 5 років тому

      Mlab is Now part of the MongoDB family... so atlas too :)

    • @sahelee1
      @sahelee1 5 років тому +1

      can anyone tell me how to do that??

    • @aozdesigns6675
      @aozdesigns6675 4 роки тому

      @@sahelee1 did you know how to do that?

  • @chideramodili5272
    @chideramodili5272 Рік тому +1

    very nice thank you very much 🤩🤩😊 you are the best teacher i have had so far...
    but please can you make an api where users can make and reply a post using mongoDB🙃

  • @chrisgermann7414
    @chrisgermann7414 5 років тому +11

    Maaaannn you are my Hero! I struggled so long with all this stuff and finally I really really get it. Thx a lot for your tutorial! It was amazing :D

  • @kingakurzawa9982
    @kingakurzawa9982 4 роки тому +2

    Hi, today I created an account on this page. From last year it was changed and I can't make a new Cluster for free. I can't create with SANDBOX. I need to create API for my own small project so what I can do?

  • @Sconner87
    @Sconner87 5 років тому +8

    Great tutorial, I'd love to see the front-end as a part two of this tutorial. Keep up the great work!

  • @stephanieraymos4675
    @stephanieraymos4675 4 роки тому +2

    Having an issue where postman just loads infinitely when trying to post, ends with a "socket hang up". Anyone know the fix?

    • @chavinduweerakoon173
      @chavinduweerakoon173 4 роки тому +2

      any updates on the issue ??

    • @joaquinlopez5234
      @joaquinlopez5234 3 роки тому

      Hey I was having the same error. On MongoDB atlas I was originally using the link to connect to MongoDB compass when you have to make sure that the link in your code is the one to connect to the drivers. Hope this helps.

  • @tiagooliveira9196
    @tiagooliveira9196 5 років тому +5

    Hey Ed, are you pretending to create a frontend tutorial to interact with this REST API ?

  • @georgekamau8361
    @georgekamau8361 Рік тому +1

    post.remove was not working for my api.i used post.deleteOne and it worked.was just curious does it mean the post.remove is depreacated

  • @developerjusta6673
    @developerjusta6673 5 років тому +5

    Please make a full tutorial building a chat app with React and Firebase! :)
    It would be really helpful!

  • @AntOriginator
    @AntOriginator 4 роки тому +2

    Great vids! I encountered a problem and I cannot solve it, since I am a noob. I cannot POST to mongodb for some reason. The message in Postman is "socket hang up". Please, help. I am stuck here. Thank you in advanced!

    • @akshbansal7715
      @akshbansal7715 4 роки тому

      Me too facing this same issue, did u found any fix?

    • @akshbansal7715
      @akshbansal7715 4 роки тому

      @@jefflaub12 try updating your ip address in Network Access

    • @jefflaub12
      @jefflaub12 4 роки тому

      @@akshbansal7715 I whitelisted my ip, no luck. Soon as it hits post.save() it hangs.

  • @vaibhavherugu9862
    @vaibhavherugu9862 4 роки тому +3

    I was building an API, and this taught me everything! Keep making videos about APIs! Thanks!

  • @maheshchandra_
    @maheshchandra_ 3 роки тому +1

    can you please tell me which theme you used in the VS Code in this video? it looks gorgeous

  • @ezeamaka
    @ezeamaka 5 років тому +5

    Awesome tutorial here, been looking for this RESTAPI with async await, it just came at the right time. I would like to see you go in depth with user auth and bcrypt. You just saved a soul

    • @blazi_0
      @blazi_0 3 роки тому

      hi why middlewares not working ?
      app.use not working for me

  • @Yarinmimon
    @Yarinmimon 3 роки тому +2

    help please im getting promise rejection when trying to save post model using post.save() , i cannot solve this

  • @pixelove1100
    @pixelove1100 4 роки тому +5

    Dude, you're saving my life. Explained that even I understood whole flow and what each line of code is doing. You definetely should compete for a Nobel Prize or something. Thanks mate!

  • @OperationAndrew.
    @OperationAndrew. 4 роки тому +1

    Dev Ed please can you make another one of these videos! 🙏 And its replacement is really hard to navigate! So I am basically stuck. Yes other UA-camrs have also created this video, but they don't explain it slowly or as effectively as you!

  • @robbiekruszynski4043
    @robbiekruszynski4043 4 роки тому +4

    I'm following all the way up until 34:00(ish) for some reason when in postman I can't see the object created with the id, title, desc, etc"

    • @mattbra1397
      @mattbra1397 4 роки тому

      You need to put const bodyParser = require('body-parser'); ABOVE const app = express(); and it should work - took me 2h to figure it out and it's not in the vid

    • @BodrumDrone
      @BodrumDrone 4 роки тому

      @@mattbra1397 in postman use x-www-form-urlencoded mode dont use raw its work it to me

    • @mattbra1397
      @mattbra1397 4 роки тому +1

      @@BodrumDrone thanks for the info - we got now two solutions to the issue :)

    • @BodrumDrone
      @BodrumDrone 4 роки тому

      @@mattbra1397 i follow all information about solution.

    • @LIFE-nr1yg
      @LIFE-nr1yg 3 роки тому

      i get postman to console the first post but when i try to get it in postman it gives me only the error part. i tried with x-www-form-urlencoded, same thing. looked online for other solutions, nothing worked

  • @nseals100
    @nseals100 2 роки тому +1

    Thank You so much!!!! Great video!!! Needed this to learn the backend!!! I normally use python, flask, and sqlAlchemy. But my cohort is using the mern stack So this helped a ton!!!!

  • @FredricCliver
    @FredricCliver 4 роки тому +3

    Don’t be emotional 😂 Thank you for this good tutorial!

  • @romanchhaque3668
    @romanchhaque3668 2 роки тому +2

    I am getting error in 34 min .. When I am trying to post with postman my .catch function is running.. please someone help me

  • @andy70sok
    @andy70sok 2 роки тому +1

    Easy to follow tutorial. However, as is so often the case I am doing this more than 3 years after the video was created and it looks as though MongoDB have changed their web UI and MLab as it appears in this video is no longer there. I have managed to create a database using the new MongoDB interface but it is not clear, to me, what URI, I need to write to it. When I first created my Mongo account I was offered a URI that connects successfully with the code in the tutorial but I was not asked to create a database at that point. If I create the database, again I can get a URI for it but it looks completely different to the first one and the authentication parameters are not there. Sigh. In order to get this tutorial to work I am going to have to spend quite a bit of time figuring out how to use MongoDB.

    • @andy70sok
      @andy70sok 2 роки тому

      Oh if I try and use the original URI when the MongoDB account was created I get this error back when I post the data. "Operation `posts.insertOne()` buffering timed out after 10000ms" This doesn't surprise me as that original URI does not reference any particular mongo database. I need to understand how to correctly reference the database in mongo URI.

  • @esthersheinaagishtein1270
    @esthersheinaagishtein1270 4 роки тому +2

    For anyone doing this now, when you can't just use mlab but have to use Atlas:
    You need to click connect your cluster via application, copy and paste that string. In addition, you might have to create a DB for that cluster if you haven't already.
    To do this click the collections button on the cluster and then hit add a database.

    • @nathanhernandez726
      @nathanhernandez726 Рік тому

      You are an absolute legend for this! Postman kept returning no data on the post request and I was about to give up

  • @theunpropheticchannel9565
    @theunpropheticchannel9565 3 роки тому +1

    Great video, I have a problem though when trying to post data to my collection. The error is as follows: "MongooseError: Operation `posts.insertOne()` buffering timed out after 10000ms"
    Does anybody have a potential solution for this?

    • @hatxu4062
      @hatxu4062 3 роки тому

      Did you solve this issue?

    • @theunpropheticchannel9565
      @theunpropheticchannel9565 3 роки тому

      Unfortunately not, I've tried making requests from different computers and networks and I encounter the same error.

  • @faisalahmadi3470
    @faisalahmadi3470 Рік тому +2

    You deserve a Like, comment and subscribe

  • @anb1142
    @anb1142 4 роки тому +1

    PHP developer here,
    This is so fucking easy, I hate PHP right now

  • @felicitya.9077
    @felicitya.9077 3 роки тому +2

    Apart from being a pretty interesting teacher, you just make me laugh. You have a great personality and vibe

  • @TheRonron1994
    @TheRonron1994 4 роки тому +1

    When logging-in in MLab, it now redirects you to Atlas MongoDB which has a totally different setup with Mlab. With that said, I really can't follow the tutorial. :(

    • @xeon7879
      @xeon7879 4 роки тому

      There is basically no difference between those two. Just try again, it's quite easy to adjust

    • @turboDout
      @turboDout 4 роки тому

      You can still follow along. I'm doing the tutorial currently and have had no issues, other than navigating a different website to find how to grant access and get the string for the mongoDB connection

  • @muhammadazhar8586
    @muhammadazhar8586 4 роки тому +1

    how to setup database at mondoDb Atlas as we are not able to create new account for mlab anymore

  • @DannyGreatDane
    @DannyGreatDane 4 роки тому +1

    while hitting api from postman I am getting Could not get response. Error: socket hang up

  • @harshilshrivastava344
    @harshilshrivastava344 4 роки тому +1

    Thank you for the Tutorial Here is the code :github.com/HarshilShrivastava/Basic-Rest-API.git

  • @Itama22
    @Itama22 4 роки тому

    I have a question:
    I use exactly the same structure like you, but i have multiple routes in my app.js, not only one for posts.
    And when I POST something, like creating a new topic in a forum, but the route to forum in my app.js comes before another route like for example a route to accounts, then in MongoDB everything i post will end up in the collection of the last used route in my app.js, so I will have forum posts in my account collection.
    Someone knows, why that happens?
    like I said, my code is exactly the same, i only use multiple routes
    for reference, it looks like this:
    //Forum
    const forumRoute = require('./Routes/forum');
    app.use('/forum', forumRoute);
    //Account
    const accountRoute = require('./Routes/account');
    app.use('/account', accountRoute);

  • @lukamuse9923
    @lukamuse9923 3 роки тому +1

    how to connect mongoDB?? My postman cant send POST method..

  • @nsfmatios
    @nsfmatios 4 роки тому +1

    Just a quick PSA for the complete beginners here: this MLab used in the video is no more, MongoDB now uses Atlas, which is a lot better UX wise and you can follow along with the video quite the same way, just don't go searching to register on MLab because you won't find what you need.

  • @bl4ckmedia323
    @bl4ckmedia323 2 роки тому +1

    What an awesome tutorial. I literally went from 0 to having a functional REST API with this and no other JS/NodeJS background.
    If you cant connect to mongoDB with mongoose (like me!), make sure that your IP is whitelisted under the "Network Access" Tab

    • @subialijaz7823
      @subialijaz7823 2 роки тому +1

      Thank you.. was also struggling the same

  • @brad3201
    @brad3201 Рік тому +1

    Initializing project 0:00
    Including express 2:35
    Creating routes 3:45
    Middleware 6:17
    Connect to MongoDB database 8:24
    Creating models and API calls 20:33
    POST Requests 25:00
    GET Requests 38:33
    DELETE Requests 42:41
    PATCH Requests 45:34

  • @nick_jacob
    @nick_jacob 4 роки тому

    I'm only 23 minutes in and i'm already feeling more confident with your explanations. I've read the express documentation before this, and I went and bought a Udemy course from Brad T, and I got my money back after watching for 3 hours...Everything Brad was doing just sucked. He didn't explain anything. So i'm glad I found this resource. I'm coming to find that reading the documentation first on the website, then finding peoples tutorials on here is more valuable than buying a course. At least for some things.

  • @kevinsana8442
    @kevinsana8442 4 роки тому +1

    I am taking my first steps into junior development.
    I was tasked by my mentor to create an API with only 1 Route.
    He asked for just a 2 tier database architecture as 3 might have been difficult for me to comprehend.
    After a few hours of searching the internet, I stumbled across this video among other older videos.
    This was the only tutorial that fundamentally taught me everything i needed to know and more.
    Thank you so much for your help!
    I cannot wait see what else I can learn in programming :)

  • @SharinganCrypto
    @SharinganCrypto 2 роки тому

    thanks for this! much appreciated I learned several new concepts I hadn't seen before: the dotenv (which is extremely useful) for example...the dependency to get around the CORS policy error...all very informative.

  • @CoderDmitri
    @CoderDmitri 3 роки тому

    @Dev Ed hello, thank you so much for wonderful tutorial. Does anyone know how do I do the following: my Server.js file is located in Server folder. How do I get "start" from package.json to go one level up and then access that nodemon server.js ... so that when I type: npm start, it runs the server.js that is in server folder. I tried ../server nodemon server.js , but it didn't work

  • @winuxworx
    @winuxworx Рік тому

    Great vid. I just hope the Async and Await is explained a little more. I'm a new subscriber.
    BTW, are you able to share the code for this activity? Thanks

  • @80Vikram
    @80Vikram 4 роки тому +1

    35:04 your solution didn't work for me. I had to use below
    post.save(function (err) {
    if (err) {
    console.log(err);
    } else {
    console.log("success");
    }
    });
    Also in cloud.mongo > Network Access Given Access to everybody 0.0.0.0/0 (includes your current IP address)

    • @sagara5982
      @sagara5982 4 роки тому

      I'm getting an error named post.save(..).then(..).catch() is not a function can you help me out with this plzzz

    • @dc37wwe2kmods
      @dc37wwe2kmods 3 роки тому +1

      This really helped me a lot!
      THANK YOU SO MUCH!! God bless!

  • @AllVid
    @AllVid 3 роки тому

    Thankyou For making this video it was really helpful for me, it was really helpfull

  • @MinNyeAccount
    @MinNyeAccount 3 роки тому +1

    npm init -y to auto accept all the options in the initial package file

  • @TigasFMS
    @TigasFMS 4 роки тому +1

    34:24 I'm actually stuck here. My model doesn't get saved. The post operation on insomnia is just waiting and the document never gets saved. I'm pointing to the right database. Do I need to point to a specific collection of the database as well?
    NOTE: It works if I specify the collection. Weird.

    • @idowork23
      @idowork23 4 роки тому

      hey man how do you do that? i have the same problem

    • @TigasFMS
      @TigasFMS 4 роки тому

      @@idowork23 Add another argument to the function (string) and specify the collection. It works without specifying the collection if database and collection names are different.

    • @jacksondavis8003
      @jacksondavis8003 3 роки тому

      @@TigasFMS can you show us the code you used?

  • @adiravraham917
    @adiravraham917 4 роки тому +1

    Great turotial! Btw, for whom watches the video today - remove() is deprecated. Insted use deleteOne() method.

  • @arpielen
    @arpielen 3 роки тому +1

    17:35 "hope you still with me, cause I'm lost already, I'm tired" oh man... I feel that. I'm tired too, but I'm still here

  • @watersilk
    @watersilk 4 роки тому +1

    :S at 34:13 I'm getting an error that says "Post is not a constructor" Please help! Thanks

    • @watersilk
      @watersilk 4 роки тому +1

      I debugged this. but now it's just not working :/ postman isn't getting a response.
      Any idea what I can do?

    • @watersilk
      @watersilk 4 роки тому

      @@jefflaub12 nope! might actually use SQL/php..

  • @quyetpham8803
    @quyetpham8803 4 роки тому +2

    This is tutorial perfect, this is what I have been looking for for a long time. Thank you from VietNam !

    • @sagara5982
      @sagara5982 4 роки тому

      I'm getting an error named post.save(..).then(..).catch() is not a function can you help me out with this plzzz

  • @codewizme
    @codewizme 4 роки тому

    can you specify the dependency in the video description for next time bcos it is not comfortable for ppl like out of internet connection when they are working. and BIGGGG Thanks

  • @rolderful
    @rolderful 3 роки тому +1

    really great this course for the beginners but short ;-)

  • @GeorgesMayrink
    @GeorgesMayrink 4 роки тому +1

    Great video. Thanks heaps. The entire video was both entertaining and instructional but, to me, the cherry on the cake was the little CORS bit. Many a time I had the feeling that dealing with CORS issues was an obscure arcane practice. Who’d have known the problem was so easy to solve? Thank you and regards from Brazil.

  • @manasiroy9510
    @manasiroy9510 4 роки тому

    Your teaching technics are just amazing. Sorry to say your fingers are too big. Don't shake it's looking like a spider. :D