#35 API: Handling POST Request | Working with Express JS | A Complete NODE JS Course

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

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

  • @MuhammadUsman-ok5vs
    @MuhammadUsman-ok5vs 7 หลายเดือนก่อน +2

    Awesome Explanation

  • @MdKaif-iy5je
    @MdKaif-iy5je 7 หลายเดือนก่อน +2

    Well explained sir!

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

    Well explained. I'm Grateful🙏

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

    the middleware express.json() is responsible for parsing incoming request bodies that contain JSON data into js objects. Without this middleware, the body of the request (for example, the data sent via Postman in a POST request) would not be parsed, leaving request.body undefined.

  • @Dext-err
    @Dext-err ปีที่แล้ว

    req.body is undefined only the id is added whit 201 status m using express "^4.18.2"
    great explanation by the way thank u so much!

    • @Dext-err
      @Dext-err ปีที่แล้ว

      ```JS
      app.post('/api/v1/movies', (req, res) => {
      console.log(req.body)
      const newId = movies[movies.length - 1].id + 1
      const newMovie = Object.assign({id: newId}, req.body)
      movies.push(newMovie)
      fs.writeFile('./Data/movies.json', JSON.stringify(movies), (err) => {
      res.status(201).json({
      status: "created!",
      data: {
      movie: newMovie
      }
      })
      })
      })
      ```

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

    @procademy I have an issue where, after making a POST call, the new data is successfully saved in the JSON file. However, when I make a GET request to retrieve all the movies, only the old records are returned, and the newly added movie doesn't show up. If I restart the server and then make the GET call again, it returns all the movies, including the new one.

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

    ❤❤❤

  • @Kiran-khadka
    @Kiran-khadka ปีที่แล้ว +2

    Undoubtedly, your content is great!
    Can you help where can I get resources for further practice and learning thought it seems obvious to someone but there lot of resources in the internet:
    How to find great resource and keep upskilling ownself:
    I'm looking forward for your kind
    Reply 🖤

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

      I am not a professional but I would recommend chatGPT, there's many questions that I would feel embarrassed to ask humans because it feels it should be obvious but with AI I can ask it 99999 silly questions and it would replay with structured, clear replies!

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

    I'm only getting curly braces {} with nothing in them, despite the countless times I have reviewed my code.
    what could be the issue here?

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

      Can you please post your post api code here?

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

      Thank you,,, but I already figured.@@procademy

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

    Why not use spread operator to create a new object ? const newMovie = {id:newId, ...reg.body}

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

      Yes you can do that...that is also an option.