0

I am using this library getmac to get the MAC address of the server on which the nodejs is running. Basically the API to get the MAC address is async but I want to use it as sync call. Is this possible without using any libraries like sync, deasync etc?

//async API require('getmac').getMac(function(err,macAddress){ if (err) throw err console.log(macAddress) })

2

1 Answer 1

1

You can use this package

var done = false;
require('getmac').getMac(function(err,macAddress) { 
    if (err) throw err 
    console.log(macAddress)
    done = true;
});
require('deasync').loopWhile(function(){return !done;});
Sign up to request clarification or add additional context in comments.

1 Comment

Basically I wanted to avoid using a new library because that would need re-issuing the whole environment but anyway I can live with this one. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.