1.js file
var a = function(){
var dfd = $q.defer();
http1().then( function( response1 ) {
http2(response1).then(function( response2 ) {
dfd.resolve(response2);
));
return dfd.promise;
}
2.js file
a().then(function( response ){
// this response is response2
// but what in future I wanted to access response1
// one way is change the response of a() and include response2 in a object
// but this will require a lot of changes at all places where a() is called.
}
)
But if we have a facility of global temporary variable then it will require a minor change.
This variable should be temporary because it should not interfere the next request.
The scope of this variable should be for onerequest only.
var a = function(){
var dfd = $q.defer();
http1().then( function( response1 ) {
GlobalTempVariable.response1 = response1;
http2(response1).then(function( response2 ) {
dfd.resolve(response2);
));
return dfd.promise;
}
2.js
a().then(function( response ){
// I will be able to access response2
// GlobalTempVariable.response1
}
)
Is there any nice way to do this?