@@ -10,7 +10,7 @@ The plugin provides services for making web requests and handle responses using
1010
1111Add ` vue ` and ` vue-resource ` to your ` package.json ` , then ` npm install ` , then add these lines in your code:
1212
13- ``` javascript
13+ ``` js
1414var Vue = require (' vue' );
1515
1616Vue .use (require (' vue-resource' ));
@@ -20,14 +20,14 @@ Vue.use(require('vue-resource'));
2020
2121Set default values using the global configuration.
2222
23- ``` javascript
23+ ``` js
2424Vue .http .options .root = ' /root' ;
2525Vue .http .headers .common [' Authorization' ] = ' Basic YXBpOnBhc3N3b3Jk' ;
2626```
2727
2828Set default values inside your Vue component options.
2929
30- ``` javascript
30+ ``` js
3131new Vue ({
3232
3333 http: {
@@ -70,7 +70,7 @@ The http service can be used globally `Vue.http` or in a Vue instance `this.$htt
7070
7171### Example
7272
73- ``` javascript
73+ ``` js
7474new Vue ({
7575
7676 ready : function () {
@@ -110,7 +110,7 @@ The resource service can be used globally `Vue.resource` or in a Vue instance `t
110110
111111### Default Actions
112112
113- ``` javascript
113+ ``` js
114114get: {method: ' GET' },
115115save: {method: ' POST' },
116116query: {method: ' GET' },
@@ -120,7 +120,7 @@ delete: {method: 'DELETE'}
120120```
121121
122122### Example
123- ``` javascript
123+ ``` js
124124new Vue ({
125125
126126 ready : function () {
@@ -155,7 +155,7 @@ new Vue({
155155
156156Interceptors can be defined globally and are used for pre- and postprocessing of a request.
157157
158- ``` javascript
158+ ``` js
159159Vue .http .interceptors .push ({
160160
161161 request : function (request ) {
@@ -169,26 +169,20 @@ Vue.http.interceptors.push({
169169});
170170```
171171
172- #### Interceptor Factory
172+ A factory function can also be used.
173173
174- If Promises are needed inside of a Interceptor, a factory function can be used.
175-
176- ``` javascript
177- Vue .http .interceptors .push (function (Promise ) {
174+ ``` js
175+ Vue .http .interceptors .push (function () {
178176 return {
179177
180- request : function (request ) {
181- if (reject) {
182- return Promise .reject ();
183- }
184- },
178+ request : function (request ) {
179+ return request;
180+ },
185181
186- response : function (response ) {
187- if (reject) {
188- return Promise .reject ();
189- }
190- }
182+ response : function (response ) {
183+ return response;
184+ }
191185
192- };
186+ };
193187});
194188```
0 commit comments