title: local storage not storing data
body: <p>I am building a Login Page for my web site,</p>
  <p><strong>client side code</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;div class=&quot;header&quot;&gt;
      &lt;h1&gt;create new account&lt;/h1&gt;
  &lt;/div&gt;
  &lt;div class=&quot;container&quot;&gt;
      &lt;div class=&quot;form&quot;&gt;
          &lt;form action=&quot;/api/db&quot; method=&quot;POST&quot;&gt;
              &lt;div&gt;
                  &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; 
                     placeholder=&quot;name&quot; required/&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type=&quot;password&quot; name=&quot;password&quot; 
                  id=&quot;password&quot; placeholder=&quot;password&quot; required&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;button type=&quot;submit&quot;&gt;create new 
                                          account&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
  &lt;script&gt;
      let name = document.querySelector('#name').value
      let password = document.querySelector('#password').value
      let form = document.querySelector('form')
      const { cookie } = document
      form.addEventListener('submit', (e) =&gt; {
        localStorage.setItem('name', name)
        localStorage.setItem('password', password)
      })
  &lt;/script&gt;
  </code></pre>
  <p><strong>server code</strong></p>
  <pre><code>class User {
     constructor(name, password) {
       this.name = name
       this.password = password
     }
   }
   const Datastore = require('nedb')
   const express = require('express')
   const app = express()
   const database = new Datastore('database.db')
   database.loadDatabase()
  
   app.post('/api/db', (req, res) =&gt; {
      let name = req.body.name
     let password = req.body.password
     database.insert(new User(name, password))
     res.redirect('/chat')
   })
  </code></pre>
  <p>I have a name input and password input inside a form, and when the user submit the form the script should save the name and the password in the localStorage but when I check the localstorage in the &quot;application&quot; tab the values of the items are &quot;undefined&quot;</p>
  <p>Edit:
  #oops I just realized how dumb my question was</p>