Curl via xmlhttprequest with retries

node v8.9.4
version: 1.0.0
endpointsharetweet
var retries = 0; var MAX_RETRIES = 3; var XML = require('xmlhttprequest').XMLHttpRequest; var url = "https://www.gfoogle.com/querty"; CURL(url); function CURL(url) { var xml = new XML; xml.onerror = function(err) { console.log("ERROR: " + xml.status + " " + xml.statusText); retries++; if (retries > MAX_RETRIES) { console.error("max retries reached"); } else { console.log("retry ", retries); CURL(url); } } /*xml.onreadystatechange = function() { console.log("readystatechange: " + xml.readyState); }*/ xml.onload = function() { console.log("load.readystate: " + xml.readyState); if (xml.readyState === 4) { console.log("DONE httpstatus " + xml.status + " " + xml.statusText); } else { console.log("httpstatus " + xml.status + " " + xml.statusText); } } xml.open("GET", url, true); console.log("connected..."); xml.send(null); }
Loading…

no comments

    sign in to comment