0
我的應用程序中有PUT請求的問題。我正在使用帶有standart fetch請求的redux-form。當我把我的請求,我得到了錯誤:PUT http://localhost:8080/auth 500(內部服務器錯誤),「語法錯誤:意外的令牌<」 還有就是我的代碼獲取:Reduce-form方法中的500(內部服務器錯誤)「PUT」
export default async function submit(fields, dispatch) {
console.trace()
const {email, fullName, company, industry, phone} = fields
let errors
if (!email)
errors = {
...errors,
email: 'Email cannot be empty'
}; else if (!/[a-z0-9._%+-][email protected][a-z0-9.-]+\.[a-z]{2,}/i.test(email))
errors = {...errors, email: 'Email seems invalid'};
if (!fullName)
errors = {...errors, fullName: 'Full name cannot be empty'};
if (!company)
errors = {...errors, company: 'Company name cannot be empty'};
if (!industry)
errors = {...errors, industry: 'Industry should be selected'};
if (errors) {
return Promise.reject(errors)
}
const response = await fetch('/auth', {
credentials: 'same-origin',
method: 'PUT',
body: Object.keys(fields)
.filter(prop => fields[prop] !== undefined)
.reduce((fd, prop) => {
fd.append(prop, fields[prop])
return fd
}, new FormData())
});
if (response.ok) {
console.log('good');
console.log(response);
} else {
const data = await response.json();
console.log('bad');
console.log(response);
}
}
什麼可能是錯的呢?