ความคิดเห็น •

  • @ubarjaktarev
    @ubarjaktarev ปีที่แล้ว +25

    Here's the raw JSON (the one posted below didn't work for me for some reason):
    {
    "title": "The Final Empire",
    "author": "Brandon Sanderson",
    "rating": 9,
    "pages": 420,
    "genres": ["fantasy", "magic"],
    "reviews": [
    { "name": "Shaun", "body": "Couldn't put this book down."},
    { "name": "Chun-li", "body": "Love it."}
    ]
    }

    • @nguyentoanhnt
      @nguyentoanhnt ปีที่แล้ว +5

      I think you misses the code line:
      app.use(express.json());

    • @keshavabanda3420
      @keshavabanda3420 ปีที่แล้ว

      @@nguyentoanhnt thank you for this information i also missed this

    • @aurelienbargain8984
      @aurelienbargain8984 ปีที่แล้ว

      thanks bro you saved me

    • @MieMie-zp1lo
      @MieMie-zp1lo ปีที่แล้ว

      @@nguyentoanhnt Thank you , I also forgot it. 😀

  • @dandendrasingh7326
    @dandendrasingh7326 2 ปีที่แล้ว +32

    Hi shuan looks like the video number in title is wrong it should be 20. Thanks for all the videos

  • @BenNouba
    @BenNouba 10 หลายเดือนก่อน

    Thanks for the great tutorial.
    If anyone faced the problem that when making a post request it just makes a new document with only the id, this is because in postman you need to change (body > raw) from text into json

  • @Mong-Yun_Chen_54088
    @Mong-Yun_Chen_54088 2 ปีที่แล้ว +36

    4:14
    {
     "title": "The Final Empire",
    "author": "Brandon Sanderson",
    "ratinig": 9,
    "pages": 420,
    "genres": [
    "fantasy",
    "magic"
    ],
    "reviews": [
    {
    "name": "Shaun",
    "body": "Couldn't put this book down."
    },
    {
    "name": "Chun-Li",
    "body": "Love it."
    }
    ]
    },

    • @ericcarver7465
      @ericcarver7465 2 ปีที่แล้ว +6

      so 2 minor problems here:
      1) You misspelled Rating
      2) you have a comma after the data, which if you try to post it with the comma, the post fails.

    • @SuperShiwi
      @SuperShiwi ปีที่แล้ว +3

      @@ericcarver7465 {
       "title": "The Final Empire",
      "author": "Brandon Sanderson",
      "rating": 9,
      "pages": 420,
      "genres": [
      "fantasy",
      "magic"
      ],
      "reviews": [
      {
      "name": "Shaun",
      "body": "Couldn't put this book down."
      },
      {
      "name": "Chun-Li",
      "body": "Love it."
      }
      ]
      }

    • @pchound5962
      @pchound5962 ปีที่แล้ว

      Awesome book btw.

  • @alexpiano
    @alexpiano 2 ปีที่แล้ว +8

    I like to use async await:
    exports.postBook = async (req, res) => {
    const newBook = req.body;
    let db = getDb();
    try {
    const result = await db.collection('books').insertOne(newBook);
    res.status(200).json(result);
    } catch (error) {
    res.status(500).json({ msg: 'Could not post new object.' });
    }
    };

  • @DavePerth
    @DavePerth 2 ปีที่แล้ว +3

    I think this should be #20 !

  • @jawadshaikh1745
    @jawadshaikh1745 2 ปีที่แล้ว

    your way of teaching is awesome, love from PAKISTAN ❤️❤️❤️

  • @darkmojojojo
    @darkmojojojo 2 ปีที่แล้ว

    @The Net Ninja Great stuff. The course lesson should be Tutorial #20 but it says #10. Thank you :D.

  • @abdellahiaioun8430
    @abdellahiaioun8430 7 หลายเดือนก่อน

    Thank you

  • @iqorimane3575
    @iqorimane3575 ปีที่แล้ว +1

    thank u sooo much for this playlist

    • @NetNinja
      @NetNinja ปีที่แล้ว +1

      You're welcome 😊

  • @mathewdavies1480
    @mathewdavies1480 4 หลายเดือนก่อน +2

    If anyone is having trouble with the post request failing, I have a possible solution.
    If your request body is not being received, it is most likely because newer versions of Express don't include the body parser automatically. To test if it is the body is the problem, you can console log the req.body to see if it comes up as null in the terminal upon request.
    Take the following steps to correct:
    - Stop your server and Install the body parser - npm install body-parser
    - Import the body parser at the top of the file - const bodyParser = require('body-parser');
    - Enable the body parser for the app, just below the declaration of the app - app.use(bodyParser.json());
    - Retry your request and the body parser should convert the Json and solve the problem
    This resolved the issue for me.

    • @Baitermin
      @Baitermin 2 หลายเดือนก่อน +1

      Thanks!
      It works now ❤❤

    • @alexturnered5044
      @alexturnered5044 2 หลายเดือนก่อน

      @@Baitermin I didint get it could you show me your full code
      I also get this error SyntaxError: Expected property name or '}' in JSON at position 8    at JSON.parse ()    at parse

    • @indigovivi
      @indigovivi หลายเดือนก่อน

      @@alexturnered5044 check if you're missing a comma after one of the values, i kept getting this error but i was missing a comma right after - "pages": 420

  • @okeyshourovroy2769
    @okeyshourovroy2769 2 ปีที่แล้ว

    Please also include mongodb aggregation framework with mongooses or mongodb driver (filtering and sorting sub document arrays) geojson. It would be very helpful 🙏🙏

  • @gryp255
    @gryp255 2 หลายเดือนก่อน +1

    {
    "title": "The Final Empire",
    "author": "Brandon Sanderson",
    "rating": 9,
    "pages": 420,
    "genres": [
    "fantasy",
    "magic"
    ],
    "reviews": [
    {
    "name": "Shaun",
    "body": "Couldn't put this book down."
    },
    {
    "name": "Chun-Li",
    "body": "Love it."
    }
    ]
    }

  • @stephanodev
    @stephanodev ปีที่แล้ว

    amazing tutorial man! you have a typo in ur title, it says this is tutorial #10

    • @NetNinja
      @NetNinja ปีที่แล้ว +1

      Thanks for spotting that Daniele :) should be right now

  • @aldotugasumb2366
    @aldotugasumb2366 6 หลายเดือนก่อน

    what about using docker? how can we configure that?

  • @waxinggibbons
    @waxinggibbons 5 หลายเดือนก่อน

    I only add the new _id-s to the books collection without the data 😖

  • @tundejoseph5733
    @tundejoseph5733 2 ปีที่แล้ว

    Hello Shaun, I've been trying to reach you on all platforms, I just paid for the Modern JavaScript on your website, I've having trouble downloading the videos to my pc. Is there a way you can help? Thanks

    • @tundejoseph5733
      @tundejoseph5733 2 ปีที่แล้ว

      *I'm

    • @ericcarver7465
      @ericcarver7465 2 ปีที่แล้ว

      @@tundejoseph5733 did he fix it for you?

    • @tundejoseph5733
      @tundejoseph5733 2 ปีที่แล้ว

      @@ericcarver7465 not at all
      I downloaded a video downloader extension on my browser

    • @ericcarver7465
      @ericcarver7465 2 ปีที่แล้ว

      @@tundejoseph5733 ah, guessing he would get in trouble with TH-cam if he helped with that. Glad it all worked out.

  • @apxmvrc
    @apxmvrc ปีที่แล้ว

    I am facing a problem in post request...When I add data using post query, for some reason the query keeps on processing infinitely...I am using async as well but still the problem remains the same (I am using thunderclient vscode extension for requests)....Please help!

  • @mahmoudakrm9923
    @mahmoudakrm9923 9 หลายเดือนก่อน

    it hurts so much to start your video with "alright then" without saying "gang"