Im learning how to make a very simple log in for a chrome extension im developing, I take a name and a password from two imput boxes and send them to a server using express POST method, but they are not defined when I print them. Heres the code:
The server.js:
let express = require('express');
let path = require("path");
let app = express();
app.use(express.json());
app.use(express.static(path.join(__dirname, '/CTRL')));
app.post('/CTRL', function(req, res) {
    var nombre = req.body.name;
    var passw = req.body.passw
    console.log('Nombre: ' + nombre + ' password: ' + passw);
    res.send('Nombre: ' + nombre + ' password: ' + passw);
});
app.listen('8000', function() {
    console.log('server corriendo puerto 8000');
  })
and the client:
let nombre = document.getElementById('User');
let contrasena = document.getElementById('Password');
let boton = document.getElementById('boton');
boton.addEventListener('click', sendData);
function sendData(){
    let nombreSTR = nombre.value
    let contrasenaSTR = contrasena.value
    fetch('http://localhost:8000/CTRL', {
      mode:'no-cors',
      method: 'POST',
      body: { name: nombreSTR, passw: contrasenaSTR },
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json'
      }
    });
  }
This is what I get in console:
server corriendo puerto 8000
Nombre: undefined password: undefined
 
     
     
     
    