1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | (function (define) {
|
9 | 'use strict';
|
10 |
|
11 | define(function (require) {
|
12 |
|
13 | var interceptor, when;
|
14 |
|
15 | interceptor = require('../interceptor');
|
16 | when = require('when');
|
17 |
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | return interceptor({
|
30 | init: function (config) {
|
31 | config.code = config.code || 400;
|
32 | return config;
|
33 | },
|
34 | response: function (response, config) {
|
35 | if (response.status && response.status.code >= config.code) {
|
36 | return when.reject(response);
|
37 | }
|
38 | return response;
|
39 | }
|
40 | });
|
41 |
|
42 | });
|
43 |
|
44 | }(
|
45 | typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
|
46 |
|
47 | ));
|