Reputation: 3323
So in all my research, I was not able to find any topic related to GET and POST in "Vanilla Node", Everyone was recommending to use Express.
But I wanted to learn Node.js and its complete functionality before attempting Express.
For Example:
Let's say I have an HTML file that contains a Signup form. On Submit how will I send the data to the database with "Vanilla Node"?
Thank you
Upvotes: 0
Views: 381
Reputation: 2880
You can use http core-module in Node.js. You can distinguish endpoints using request.path
and handle it accordingly. For more ideas Refer HTTP module
const http = require("http");
const server = http.createServer((req, res) => {
if (req.method === "POST") {
// For all POST REQUESTS
} else {
}
});
server.listen(3000);
Upvotes: 1