1 | # @fatcherjs/middleware-json
|
2 |
|
3 | A middleware for transform response to JSON
|
4 |
|
5 | ## Install
|
6 |
|
7 | ### NPM
|
8 |
|
9 | ```bash
|
10 | >$ npm install @fatcherjs/middleware-json
|
11 | ```
|
12 |
|
13 | ### CDN
|
14 |
|
15 | ```html
|
16 | <script src="https://cdn.jsdelivr.net/npm/@fatcherjs/middleware-json/dist/json.min.js"></script>
|
17 | ```
|
18 |
|
19 | ## Usage
|
20 |
|
21 | ```ts
|
22 | import { json } from '@fatcherjs/middleware-json';
|
23 | import { fatcher } from 'fatcher';
|
24 |
|
25 | fatcher({
|
26 | url: '/bar/foo',
|
27 | middlewares: [json()],
|
28 | payload: {
|
29 | bar: 'foo',
|
30 | },
|
31 | })
|
32 | .then(res => {
|
33 | console.log(res);
|
34 | })
|
35 | .catch(err => {
|
36 | console.error(error);
|
37 | });
|
38 | ```
|
39 |
|
40 | ## License
|
41 |
|
42 | [LICENSE](https://github.com/fatcherjs/fatcher/blob/master/LICENSE)
|