Function return in NodeJS how get?

166
December 11, 2020, at 6:20 PM

i am trying to get value for function in ping lite, my return is undefinied,

my code is

    async TesteMyPing(request: Request, response: Response) {
    var Ping = require('ping-lite'); // import ping-lite
    var ping = new Ping('uol.com.br'); // website for ping

    var test = ping.send(function (err: any, ms: any) {
        return ms;
    });

    console.log(test) // return Undefinied

    return response.status(200).json(teste); // response for client Undefinied
}

how get value for is variable in nodejs, to be work on the rest of the function body? ty,

READ ALSO
Noobie in javascript, trying to have a select button [closed]

Noobie in javascript, trying to have a select button [closed]

Want to improve this question? Update the question so it's on-topic for Stack Overflow

107
Display and autoplay youtube video in popup on document load

Display and autoplay youtube video in popup on document load

I am trying to autoplay a youtube video in a popup 5 seconds after document load, unfortunately, it's not working:

143
How to use get method in raspberry pi3? [closed]

How to use get method in raspberry pi3? [closed]

Want to improve this question? Add details and clarify the problem by editing this post

109
How to use a global variable in several files

How to use a global variable in several files

I was trying to use a global variable in a React app for debugging purposes, and ran into some issues that made me realize that I don't understand how global variables in javascript works

89