In my Node.js file I am using http.createServer in order to return some data from my server. Inside of my function, when the endpoint is called, I would like to call some async function in order to return some data. Could someone explain to me what I am doing wrong? When I do a request at the endpoint I get back the error: "UnhandledPromiseRejectionWarning: RequestError: Error: socket hang up"Could you explain how I can achieve this correctly please?I am using the code:var server = http.createServer(function (request, response) {console.log('request starting...');const ticket = "n/a"ticket = SOME_ASYNC_FUNCTION()response.write(ticket);response.end();});server.listen(8089);function SOME_SOME_ASYNC_FUNCTION(){return "12345"}
Submitted November 05, 2019 at 04:57AM by jjj123smith
No comments:
Post a Comment