خرید بک لینک

Vote count: 0

I am new to nodejs, I am making multiple get requests with request nodejs api, with this, I am unable to figure out output of a particular request. How to identify the response of each request individually ? I am using for loop to send multiple requests. If i use recursion, it becomes again synchronous, i just have to separate request with response that too asynchronous. Is it possible ?

In the below code variable 'i' is replace by last iteration .

var list = [ 'http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=%20Mobiles%20with%20best&phrase2=Mobiles%20with%20best',
      'http://swoogle.umbc.edu/SimService/GetSimilarity?operation=api&phrase1=%2520Mobiles%2520with%2520best&phrase2=what%20is%20a%20processor']

function ss(list){
    for(var i in list) {
        request(list[i], function (error, response, body) {
            if (!error && response.statusCode == 200) {
                console.log( i + " " +body);
            }
        })
    }
}

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 18 خرداد 1395 ساعت: 0:06

صفحه بندی