mercredi 15 avril 2015

How do I filter a list of urls by 200 response?

Basically, I have a list of 30 urls, and I want to do a request({ method: 'head', url: url }).then(function(data){});


The problem I'm having is that the request-promise is difficult to deal with because a 404 would trigger a .catch not a .then.


I basically just need to make sure these urls have a 200 response and if not remove them from the list.


I've tried with basic async and request (callback interface) but can't seem to wrap my head around it.


Just assume I have an array of urls to check and I want the function to return me that list filtered by 200 responses.


Aucun commentaire:

Enregistrer un commentaire