'my file in my dbb is undefined when i post with a picture

Hello in my app when i want to post a picture or a text with my picture. My console array tell me this : "http://localhost:8000/images/undefined" i don't really understand why the app find the folder but not the files

here is my route with node:

 `router.post("/", (req, res) => {
    
      const content = req.body.content;
      const media = `${req.protocol}://${req.get('host')}/images/${req.body.media.filename}`;
      const firstname = req.body.firstname;
      const lastname = req.body.lastname;
    
      db.query(
        "INSERT INTO posts ( content, image_path, firstname, lastname) VALUES (?, ?, ?, ?);",
        [content, media, firstname, lastname],
        (err, results) => {
          console.log(err);
          res.send(results);
        }
      );
    });`

[and here is my info from the BDD][1]

i would like to know how can i fix this. i use React for my app [1]: https://i.stack.imgur.com/NpapI.png



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source