axios-mock-shim
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -91,3 +91,3 @@ /* eslint-disable */ | ||
const { $instance, $options } = this; | ||
const { beforeResponse, catchError } = $options; | ||
const { beforeResponse } = $options; | ||
if (!httpMethodList.has(method.toUpperCase())) | ||
@@ -101,5 +101,4 @@ return warn('Invalid http method', method); | ||
: 'data']: data, | ||
}).then(beforeResponse ? beforeResponse : (res) => res) | ||
.catch(catchError ? catchError : (err) => err); | ||
}).then(beforeResponse ? beforeResponse : (res) => res); | ||
}, | ||
}; |
{ | ||
"name": "axios-mock-shim", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A plugin build for easily using axios-mock-adapter with axios", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -140,2 +140,16 @@ # Axios Mock Shim | ||
### beforeResponse | ||
You can specify what to do before getting the response, eg. | ||
```js | ||
const api = createAPIHandler(instance, { | ||
useMock: true, | ||
beforeResponse(res) { | ||
return camelizeKeys(res.data); | ||
}, | ||
}); | ||
``` | ||
### anyReply | ||
@@ -142,0 +156,0 @@ |
@@ -16,3 +16,2 @@ export interface MockAdapterOptions { | ||
beforeResponse?: Function; | ||
catchError?: Function; | ||
} | ||
@@ -19,0 +18,0 @@ |
15846
206
330