0

Is it possible for me to get the data from body.message to use outside that function?

I've tried this so far.

    var codetocheck;
    request({
        url: link,
        json: true
    },function (err, resp, body){
        codetocheck = body.message;//var I want to use outside this function
    })
Iwo
  • 3
  • 1
  • 4
  • 2
    Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Hamza El Aoutar Oct 01 '19 at 14:56
  • I am not sure I understand your question. Can you please elaborate? – rahul_sann Oct 01 '19 at 15:01

1 Answers1

0

The following solutions can help you to return the data after making an asynchronous call.

Solution 1: You can make use of promises, for any reference, please check the link promises

Solution 2: Please check in here for how to return the data using callback after making an asynchronous call, Using callbacks for returning data