I'm trying to send form data to server in a Nextjs/express app.When I press 'submit',I can't see any output is sent to server.
I tried the following code and had no success and I can't understand why it is not working because I'm totally a newbie to this stack.File structure of my project is as follows.
index.js
class Index extends Component{
render(){
return(
<form action="/server" method="post">
<input type="text" id="name"></input>
<input type="submit"/>
</form>
);
}
}
server.js
server.post('/server', (req, res) => {
const name = req.body
res.send(name)
})
I want the webpage show the data that I entered into input field in the form.instead,it shows only a couple of curly braces( {} ).
