@@ -134,7 +134,7 @@ Interceptors can be defined globally and are used for pre- and postprocessing of
134
134
135
135
### Request processing
136
136
``` js
137
- Vue .http .interceptors .push (function (request , next ) {
137
+ Vue .http .interceptors .push (function (request ) {
138
138
139
139
// modify method
140
140
request .method = ' POST' ;
@@ -143,39 +143,37 @@ Vue.http.interceptors.push(function(request, next) {
143
143
request .headers .set (' X-CSRF-TOKEN' , ' TOKEN' );
144
144
request .headers .set (' Authorization' , ' Bearer TOKEN' );
145
145
146
- // continue to next interceptor
147
- next ();
148
146
});
149
147
```
150
148
151
149
### Request and Response processing
152
150
``` js
153
- Vue .http .interceptors .push (function (request , next ) {
151
+ Vue .http .interceptors .push (function (request ) {
154
152
155
153
// modify request
156
154
request .method = ' POST' ;
157
155
158
- // continue to next interceptor
159
- next ( function (response ) {
156
+ // return response callback
157
+ return function (response ) {
160
158
161
159
// modify response
162
160
response .body = ' ...' ;
163
161
164
- }) ;
162
+ };
165
163
});
166
164
```
167
165
168
166
### Return a Response and stop processing
169
167
``` js
170
- Vue .http .interceptors .push (function (request , next ) {
168
+ Vue .http .interceptors .push (function (request ) {
171
169
172
170
// modify request ...
173
171
174
172
// stop and return response
175
- next ( request .respondWith (body, {
173
+ return request .respondWith (body, {
176
174
status: 404 ,
177
175
statusText: ' Not found'
178
- })) ;
176
+ });
179
177
});
180
178
```
181
179
@@ -184,9 +182,8 @@ Vue.http.interceptors.push(function(request, next) {
184
182
All default interceptors callbacks can be overriden to change their behavior. All interceptors are exposed through the ` Vue.http.interceptor ` object with their names ` before ` , ` method ` , ` jsonp ` , ` json ` , ` form ` , ` header ` and ` cors ` .
185
183
186
184
``` js
187
- Vue .http .interceptor .before = function (request , next ) {
185
+ Vue .http .interceptor .before = function (request ) {
188
186
189
187
// override before interceptor
190
188
191
- next ();
192
189
};
0 commit comments