title: trying to update user getting error Cannot POST /update-user
body: <p>Hello when i try to update user on page i get error Cannot POST /update-user
  cannot find there is a problem can someone see there is a mistake was done code below
  <a href="https://i.stack.imgur.com/54DDz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/54DDz.png" alt="enter image description here" /></a></p>
  <p>index.js</p>
  <pre><code>$('#add_user').submit(function(event){
      alert(&quot;Informacija išsaugota!&quot;)
  })
  
  $('#update-user').submit(function(event){
      event.preventDefault();
  
  let unindexed_array =$(this).serializeArray();
  let data = {}
  $.map(unindexed_array,function(n,i){
  data[n['name']]= n['value']
  })
  
  console.log(data)
  
  let request = {
      &quot;url&quot; : `http://localhost:3000/api/users/${data.id}`,
      &quot;method&quot; : &quot;PUT&quot;,
      &quot;data&quot; : data
  }
  
  $.ajax (request).done(function(response){
      alert(&quot;Naudotojas Atnaujintas!&quot;)
  })
  
  })
  
  if(window.location.pathname == &quot;/&quot;){
      $ondelete=$(&quot;.table tbody td a.delete&quot;);
      $ondelete.click(function(){
          let id = $(this).attr(&quot;data-id&quot;)
     
          let request = {
              &quot;url&quot; : `http://localhost:3000/api/users/${id}`,
              &quot;method&quot; : &quot;DELETE&quot;,
     
          }
     
     if(confirm(&quot;Ar tikrai norite ištrinti įraša?&quot;)){
      $.ajax (request).done(function(response){
          alert(&quot;Naudotojas ištrintas!&quot;)
      location.reload()
      })
     }
     
      })
  
  }
  </code></pre>
  <p>ROUTER.JS</p>
  <pre><code>const express = require('express');
  const route = express.Router()
  
  const services = require('../services/render')
  const controller = require('../controller/controller')
  
  /**
   * @description Root Route
   * @method GET/
   */
  
  route.get('/',services.homeRoutes)
      
  /**
   * @description add users
   * @method GET/ add-user
   */    
  
      route.get('/add-user',services.add_user)
          
  /**
   * @description for update user
   * @method GET/  update-user
   */  
  
      route.get('/update-user',services.update_user)
      
      // API
      
      route.post('/api/users',controller.create);
      route.get('/api/users',controller.find);
      route.put('/api/users/:id',controller.update);
      route.delete('/api/users/:id',controller.delete);
  
      module.exports = route
  </code></pre>
  <p>_show.ejs</p>
  <pre><code>&lt;%for(var i = 0; i &lt;users.length; i++){%&gt;
  
  &lt;tr&gt;
      &lt;td&gt;&lt;%= i + 1%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=users[i].name%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=users[i].email%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=users[i].Lytis%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=users[i].status%&gt;&lt;/td&gt;
      &lt;td&gt;
          &lt;a href=&quot;/update-user?id=&lt;%=users[i]._id%&gt;&quot; class=&quot;btn border-shadow update&quot;&gt;
              &lt;span class=&quot;text-gradient&quot;&gt;&lt;i class=&quot;fas fa-user-edit&quot;&gt;&lt;/i&gt;&lt;/span&gt;
          &lt;/a&gt;
          &lt;a class=&quot;btn border-shadow delete&quot; data-id=&lt;%=users[i]._id%&gt;&gt;
           &lt;span class=&quot;text-gradient&quot;&gt;&lt;i class=&quot;fas fa-user-slash&quot;&gt;&lt;/i&gt;&lt;/span&gt;
       &lt;/a&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  &lt;%}%&gt;
  </code></pre>
  <p>Try to search andchange some methods but nothing works and stuck now
  its can be wrong ejs i gues . Or something else .
  And how to consolelog all details coming from backend or from front end ?</p>