Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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.
- */
- // Problem 1
- var promise1 = $http({url: 'http://www.foobar.com', cache:'false'
- }).then(function(response1){
- //process response1
- return response1
- },function(response){
- //process error
- }) ;
- var promise2 = $http({url: 'http://www.foobar.com', cache:'false'
- }).then(function(response2){
- //process response2
- return response2
- },function(response){
- //process error
- }) ;
- /* 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 */
- $q.all([promise1,promise2]).then(function(response){
- for (var x=0,x<response.length;x++) {
- //process response1 and response2
- }
- return processedResponses ;
- }
- /* Problem 2
- 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
- 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??
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement