View difference between Paste ID: XTpMhn8d and hRPBb2mq
SHOW: | | - or go back to the newest paste.
1-
var call1 = $http({url: 'http://www.foobar.com', cache:'false'
1+
/* My $http({}).then()s are all working, I am getting the exact responses/errors I want and am able to process them and spit info back out to my webpage, but now I am trying to control WHEN the $https get called. My method below, obviously isn't working.
2
*/
3
4
// Problem 1
5
var promise1 = $http({url: 'http://www.foobar.com', cache:'false'
6
	}).then(function(response1){
7
		//process response1
8
		return response1
9-
var call2 = $http({url: 'http://www.foobar.com', cache:'false'
9+
10
		//process error
11
	}) ;
12
13
var promise2 = $http({url: 'http://www.foobar.com', cache:'false'
14
	}).then(function(response2){
15
		//process response2
16
		return response2
17-
$q.all([call1,call2]).then(function(response){
17+
18
		//process error
19
	}) ;
20
21
/* promise1 and promise1 are executing immediately upon assignment.  Whether I want to execute them or not, they are being executed. My goal is to store the promise1/promise2 as vars or functions to then be executed within the $q.all() ;...and to execute them again when ever I want.  Even if I completely comment out the $q.all() below, the above $https are still executed as I can see the website calls being logged in the inspector/debug  */
22
23
$q.all([promise1,promise2]).then(function(response){
24-
// Because call1 and call2 are pretty much identical, I should see the same data twice in "processedResponses" - and I am.  
24+
25-
// however in the inspector/debug tool I am only seeing ONE call to http://www.foobar.com when I am expecting to see two calls
25+
26-
// 
26+
27-
// Thus is call2 not actually happening because call1 is cached and thus response2 is simply pulled from response1???
27+
28
}
29
30
/* Problem 2
31
Regardless of when promise1/promise2 are executed, because promise1 and promise2 are identical, I should see the same data twice in "processedResponses" - and I am. however in the inspector/debug tool I am only seeing ONE call to http://www.foobar.com when I am expecting to see two calls
32
33
Thus is promise2 not actually happening because promise1 is cached and thus response2 is simply pulled from response1???  Why am I not seeing TWO url calls to www.foobar.com??
34
*/