I'm writting a module that makes a call to an URL using http.request method. I need to process the result of the request but I'm not sure the right way to do it. I've tried this:
Code: Select all
http.request({
method: 'GET',
url: encodeURI(myURL),
success: function (response) {
console.log("Success!");
},
error: function () {
console.log("ERROR!!");
}
});
Code: Select all
http.request({
method: 'GET',
url: encodeURI(myURL),
}, function (response) {
console.log("Callback!");
});
Code: Select all
var response = http.request({
method: 'GET',
url: encodeURI(myURL),
});
console.log(JSON.stringify(response));