Last change
on this file since 463 was
463,
checked in by hendrikvanantwerpen, 12 years ago
|
Working towards Heroku deployment, restructuring for that and to allow coffee builds.
|
File size:
972 bytes
|
Line | |
---|
1 | define([ |
---|
2 | "dojo/Deferred", |
---|
3 | "dojo/request" |
---|
4 | ], function(Deferred, request) { |
---|
5 | |
---|
6 | var authenticated = true; |
---|
7 | var queue = []; |
---|
8 | |
---|
9 | var _request = function(url, options) { |
---|
10 | var dfd = new Deferred(); |
---|
11 | if ( authenticated ) { |
---|
12 | request(url,options).response.then(function(response){ |
---|
13 | console.log(response); |
---|
14 | }, function(error){ |
---|
15 | if ( error.response.status === 401 ) { |
---|
16 | queue.push({ |
---|
17 | url: url, |
---|
18 | options: options, |
---|
19 | dfd: dfd |
---|
20 | }); |
---|
21 | console.log("Retry goes here :)"); |
---|
22 | } else { |
---|
23 | dfd.reject(error); |
---|
24 | } |
---|
25 | }); |
---|
26 | } else { |
---|
27 | queue.push({ |
---|
28 | url: url, |
---|
29 | options: options, |
---|
30 | dfd: dfd |
---|
31 | }); |
---|
32 | } |
---|
33 | return dfd.promise; |
---|
34 | }; |
---|
35 | return _request; |
---|
36 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.