var request = require('request');
request("http://example.com/index.php?username=username&password=password, function (error, response, body) {
var n1 = body.search('<user>');
var n2 = body.search('</user>');
var final = body.slice(n1+6, n2);
//it is working perfectly here.
final10 = final;
});
//The problem is that i can not call the "body" or variable "Final10" outside the Scope.
var final10=request.body
Hi, I am Newbie in Node JS. I am trying to make a Experimental Bot. i am using "request" to send a "Get" to my website. there through "Php", it is getting saved in "Mysqli" database.
Everything is working fine and i am getting the result. but, as i had got the data required, i can not access it. How can i get access to the 'body' of 'Request' from outside the function?
Please refer above to the code
Is there any way, to call it outside of it? that i can manage my code more easily
Please Note: it is just a little snap of the code the real code. the real code got a lot of if/else, loops and other functions. Turing it into bracket under brackets will be little complicated.
Thankyou