score:1

Accepted answer

you should have a look at the documentation: promise.all()

promise.all() actually preserves the order for its returned values.

hence you could have:

const promises = [];
promises.push(fetch("http://localhost:7890/1.1/statuses/user_timeline.json?count =30&screen_name=techcrunch"));
promises.push(fetch("http://localhost:7890/1.1/statuses/user_timeline.json?count=30&screen_name=laughingsquid"));
promises.push(fetch("http://localhost:7890/1.1/statuses/user_timeline.json?count=30&screen_name=appdirect"));
// execute all promises
promise.all(promises).then(values => {
    console.log(values);
    const twitterfeed = { ...this.state.twitterfeed};
    twitterfeed.techcrunch = json.parse(values[0]);
    twitterfeed.laughingsquid = json.parse(values[1]);
    twitterfeed.appdirect = json.parse(values[2]);
    this.setstate({
        isloadcomplete: true,
        twitterfeed
    });
});

score:1

if you are familiar with the axios library.you can use there axios.all([]) calling method. as mentioned in there docs :

function a() {
  return axios.get(url,[config]);
}

function b() {
  return axios.get(url,[config]);
}

axios.all([a(), b()])
  .then(axios.spread(function (result_a, result_b) {
    // both requests are now complete and you can setsate here.
}));

github : https://github.com/axios/axios

score:1

     var promise1 = fetch("http://localhost:7890/1.1/statuses/user_timeline.json?count =30&screen_name=techcrunch");

     var promise2 = fetch("http://localhost:7890/1.1/statuses/user_timeline.json?count=30&screen_name=laughingsquid");

     var promise3 =fetch("http://localhost:7890/1.1/statuses/user_timeline.json?count=30&screen_name=appdirect");

     promise.all([promise1, promise2, promise3]).then(function(values) {
        console.log(values);
    });

//you can now extend it as you want


Related Query

More Query from same tag