Skip to content

Commit bd8142c

Browse files
author
Steffan
committed
update docs
1 parent 61b1efc commit bd8142c

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

docs/http.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Interceptors can be defined globally and are used for pre- and postprocessing of
134134

135135
### Request processing
136136
```js
137-
Vue.http.interceptors.push(function(request, next) {
137+
Vue.http.interceptors.push(function(request) {
138138

139139
// modify method
140140
request.method = 'POST';
@@ -143,39 +143,37 @@ Vue.http.interceptors.push(function(request, next) {
143143
request.headers.set('X-CSRF-TOKEN', 'TOKEN');
144144
request.headers.set('Authorization', 'Bearer TOKEN');
145145

146-
// continue to next interceptor
147-
next();
148146
});
149147
```
150148

151149
### Request and Response processing
152150
```js
153-
Vue.http.interceptors.push(function(request, next) {
151+
Vue.http.interceptors.push(function(request) {
154152

155153
// modify request
156154
request.method = 'POST';
157155

158-
// continue to next interceptor
159-
next(function(response) {
156+
// return response callback
157+
return function(response) {
160158

161159
// modify response
162160
response.body = '...';
163161

164-
});
162+
};
165163
});
166164
```
167165

168166
### Return a Response and stop processing
169167
```js
170-
Vue.http.interceptors.push(function(request, next) {
168+
Vue.http.interceptors.push(function(request) {
171169

172170
// modify request ...
173171

174172
// stop and return response
175-
next(request.respondWith(body, {
173+
return request.respondWith(body, {
176174
status: 404,
177175
statusText: 'Not found'
178-
}));
176+
});
179177
});
180178
```
181179

@@ -184,9 +182,8 @@ Vue.http.interceptors.push(function(request, next) {
184182
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`.
185183

186184
```js
187-
Vue.http.interceptor.before = function(request, next) {
185+
Vue.http.interceptor.before = function(request) {
188186

189187
// override before interceptor
190188

191-
next();
192189
};

0 commit comments

Comments
 (0)