Answer the question
In order to leave comments, you need to log in
How to return control to the main function in nodejs when using http.createServer?
async function waitResolve() {
http.createServer((request, response) => {
if (request.method === 'GET') {
response.end('success');
} else {
let body = '';
request.on('data', chunk => {
body += chunk.toString();
});
request.on('end', () => {
// let params = parse(body);
console.log(body);
response.end('success');
return Promise.resolve(body);
});
}
}).listen(3000);
}
async function main() {
await waitResolve();
}
main();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question