Mongoose:Website will not update existing information

Hi all, I’ve recently added my script to include a POST method as before it only had a get and was issuing a CANNOT POST /update-user issue. The error no longer appears but now when I edit existing information on the form it does not update.

This is my route.js file

const express = require('express');
const route = express.Router();

const services = require('../services/render');

const controller = require('../controller/controller');
/* @descript Root Route
@method GET/

/* @descript add users
@method GET/ add-user

route.get('/add-user', services.add_user); 
/* @descript update users
@method GET/ update-user

//extra'/update-user', services.update_user);

route.get('/update-user', services.update_user);

//API'/api/users', controller.create);
route.get('/api/users', controller.find);
route.put('/api/users/:id', controller.update);
route.delete('/api/users/:id', controller.delete);


The next is my section on the render.js on the update-user part

exports.update_user = (req,res) =>{
        res.render('update_user',{user :});
    .catch(err =>{

This is the other update user part for my controller.js script

//Update a new identified user by user id
exports.update = (req, res) => {
    return res.status(400).send({
        message:"data to update content can not be empty"
const id =;
Userdb.findByIdAndUpdate(id, req.body,{ useFindAndModify: false})
            message:"User not found with id${id} "

and this is my index.js with update-user


    var unindexed_array = $(this).serializeArray();
    var data = {}
    $.map(unindexed_array,function(n, i){
data[n['name']] = n['value']

    var request = {
        "method": "PUT",
        alert("Data Updated Successfully!");


I am not sure what is wrong. Before it was the POST method but adding it to the router.js made the error disappear. But now, it is not updating user information by ID. I am using Mongoose library for this.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.