Skip to content

Commit

Permalink
fix: error handle, fix #39
Browse files Browse the repository at this point in the history
  • Loading branch information
vben-admin committed Aug 1, 2021
1 parent f25c6ac commit 874318c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/createProdMockServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ function __XHR2ExpressReqWrapper__(handle: (d: any) => any) {
let result = null;
if (typeof handle === 'function') {
const { body, type, url, headers } = options;

let b = body;
try {
b = JSON.parse(body);
} catch {}
result = handle({
method: type,
body: JSON.parse(body),
body: b,
query: __param2Obj__(url),
headers,
});
Expand Down

0 comments on commit 874318c

Please sign in to comment.