Skip to content

Commit ecfa811

Browse files
committed
refactor: 精简代码
1 parent 66227ae commit ecfa811

File tree

1 file changed

+4
-5
lines changed
  • src/BootstrapBlazor/wwwroot/modules

1 file changed

+4
-5
lines changed

src/BootstrapBlazor/wwwroot/modules/ajax.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414

1515
let result = null;
1616
try {
17-
const toJson = option.toJson;
18-
delete option.toJson;
19-
result = await fetch(option.url, {
20-
method: option.method,
17+
const { toJson, url, method, data } = option;
18+
result = await fetch(url, {
19+
method: method,
2120
headers: {
2221
'Content-Type': 'application/json'
2322
},
24-
body: option.method === 'POST' ? JSON.stringify(option.data) : null
23+
body: method === 'POST' ? JSON.stringify(data) : null
2524
});
2625
if (toJson === true) {
2726
result = await result.json()

0 commit comments

Comments
 (0)