Skip to content

Commit 49ec0fe

Browse files
committed
Using new api
1 parent 224f87d commit 49ec0fe

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

README.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ export default {
2424
'age|18-54': 1,
2525
}]
2626
}).list;
27-
return Promise.resolve({
27+
return {
28+
status: 200,
2829
data: all,
29-
});
30+
};
3031
},
3132
'/api/path/{id}': ({ method, url, params, urlparams, headers }) => {
3233
const all = Mock.mock({
@@ -37,9 +38,21 @@ export default {
3738
'urlid': urlparams.id,
3839
}]
3940
}).list;
40-
return Promise.resolve({
41+
return {
42+
status: 200,
4143
data: all,
42-
});
44+
};
45+
},
46+
'POST /api/path': ({ method, url, params, urlparams, headers }) => {
47+
return {
48+
status: 201,
49+
};
50+
},
51+
'PUT /api/path/${id}': ({ method, url, params, urlparams, headers }) => {
52+
return {
53+
status: 204,
54+
id: urlparams.id,
55+
};
4356
},
4457
}
4558
```
@@ -53,6 +66,24 @@ if (__dev__) {
5366
5467
// if __dev__ is true, it will back the data you defined in mock directory
5568
fetch('/api/path', options);
69+
fetch('/api/path', {
70+
method: 'POST',
71+
headers: {
72+
'Content-Type': 'application/json',
73+
},
74+
body: JSON.stringify({
75+
name: 'John',
76+
}),
77+
});
78+
fetch('/api/path/123', {
79+
method: 'PUT',
80+
headers: {
81+
'Content-Type': 'application/json',
82+
},
83+
body: JSON.stringify({
84+
name: 'John2',
85+
}),
86+
});
5687
```
5788
## LICENSE
5889

0 commit comments

Comments
 (0)