const upload = async (url, formData) => {
fetch(url, {
method: 'POST',
headers: {
'content-Type': 'multipart/form-data',
},
body: formData,
})
.then(response => (response.json()))
.catch(error => {
console.log(error);
});
};想将返回的值为json对象
fetch(url, {
method: 'POST',
headers: {
'content-Type': 'multipart/form-data',
},
body: formData,
})
.then(response => (response.json()))
.catch(error => {
console.log(error);
});
};想将返回的值为json对象
return await fetch(url, {
method: 'POST',
headers: {
'content-Type': 'multipart/form-data',
},
body: formData,
}).then(response => (response.json()))
};
upload('../FE/2018/testdata/abortcontroller.json',{})
.then(console.log);