Skip to content Skip to sidebar Skip to footer

How Return Promise From Multiple Promises

I always in console see: teamsUpdated2 addUserToProjects deleteUserFromProjects but should bee in different order var result = teamService.addOrDeleteUser(userId, newTeams,

Solution 1:

You can use promise chaining for that -

travelService
       .getDeparture( user )                                           // Request #1
       .then( function( departure ){
            $scope.departure = departure;                            // Response Handler #1return travelService.getFlight( departure.flightID );       // Request #2
        })
        .then( function( flight ){
             $scope.flight = flight;                                // Response Handler #2return weatherService.getForecast( $scope.departure.date ); // Request #3
        })
        .then( function( weather ){
            $scope.weather = weather;                               // Response Handler #3
        });

For more reference see this

Post a Comment for "How Return Promise From Multiple Promises"