2

my requiremtn is i have multiple no of url need to test one by one by get method to get response.

example follwing urls

1-https:scgncp.com/12041/. 2-https:ibm.com/120024/. ..... ....... ....... ...... ...... ..... ...... 100- no fo urls.

test using

$http(url).then(function(response)
{
//write  status of response
},function errorfunction(response){

//error status code should be display here

}

need to test 100 urls using above method or other way is there please help me

Hrishikesh Kale
  • 6,140
  • 4
  • 18
  • 27

3 Answers3

0

You need to build an Array of Promises and execute them all with: Promise.all(arrayOfPromises)

Sergio
  • 1,370
  • 11
  • 12
0

You can find in this response how to use $q to send multiple async calls

Here the idea:

var urlList = ["url1","url2","url3"];

$q.all(urlList.map(function (url) {
            return $http({
                method: 'GET',
                url: url
            });
}))
David Faure
  • 1,336
  • 14
  • 25
0

You can use a loop, to loop over all the urls and make a request for each one:

var urls = ["https:scgncp.com/12041/", "https:ibm.com/120024/"];

urls.forEach(function(url) {
  console.log("Sending a request to: " + url);
  $http(url).then(function(response) {
    //write  status of response
  }, function errorfunction(response) {
    //error status code should be display here
  });
});
cнŝdk
  • 31,391
  • 7
  • 56
  • 78