node.js - How can i redo a GET request with request module if i get an error? -
this code:
var request = require("request"); request({url:url, qs:propertiesobject}, function(err, response, body) { if(err) { console.log(err); } if (!err && response.statuscode == 200 ) { console.log(response.statuscode); } });
i don't need console.log error need redo request if err true. i'm using nodejs , request module get. can me?
var request = require("request"); var options = {url:url, qs:propertiesobject} function handleresponse(err, response, body) { if(err) { request(options, handleresponse); } if (!err && response.statuscode == 200 ) { console.log(response.statuscode); } } request(options, handleresponse);
Comments
Post a Comment