const server = http.createServer(async (request, response) => {
if (request.method === "POST") {
var data = "";
request
.on("data", async (chunk) => {
console.log("1");
data += chunk;
console.log("2");
await connection.query({sql query});
console.log("3");
})
.on("end", async () => {
console.log("4");
});
}
}
result below
1 4 2 3
Do you know how to process synchronously and make result order 1 2 3 4?
If you want to add it synchronously, why add async keyword. And besides, I preferably would go with the modern day servers and use the express package for this. Use this link: https://expressjs.com/en/starter/hello-world.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.