Can’t get user input to apply an update


Everything seems to be working in my code, except on my update I’m trying to get the user inputted text from my HTML page and apply it as an update, but it’s not working. Any ideas?

Here’s my javascript:

app.patch("/tm/v1/tasks/:id", async (req,res)=>{
  try {
    const { id } = req.params;
    const update = { name: String(document.getElementsByClassName('task-edit-name'))}
    const taskUpdated = await Task.findOneAndUpdate({id}, update, {new: true});
    res.status(200).json({taskUpdated});
  } catch (error) {
    res.status(500).json({msg: error});
  };
});

Here’s my HTML (I’m trying to get the input from this):

<div class="form-control">
  <label for="name">Name</label>
  <input type="text" name="name" class="task-edit-name" />
</div>

Source: JavaSript – Stack Overflow

November 21, 2021
Category : News
Tags: class | html | input | javascript | mongoose

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.