简体   繁体   中英

Ionic angularjs $http module is not get data

In anguler js if I used two times $http in single function so, will it affect the fetching data from web services.

Like :-
.factory('Chats', function($http) {
  $http{}
  $http{}
});

Thanks

Fetching data using two $http calls is not a problem and they will not interfere with each other because they are called asynchronously.

This is great because it means that they will both be called nearly immediately without one having to wait for the other to complete.

You should know, however, that because of this you could get the results of the second call before you get the results of the first call. This might happen if you were to have a very long call (large amount of data) in your first $http and a very short one (small amount of data). If you want to wait for both to be completed before proceeding then you can use $q.all to wait for both to complete before proceeding. You can read more about this here: https://www.jonathanfielding.com/combining-promises-angular/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM