0
私は私のreaaltアプリケーションでPUT要求にいくつかの問題があります。私はstandartフェッチ要求とredux形式を使用しています。私は私の要求を送信すると、私はエラーました:http://localhost:8080/auth 500(内部サーバーエラー)をPUT「にSyntaxError:予期しないトークン<を」フェッチのための私のコードは あり:redux-formメソッド "PUT"で500(内部サーバーエラー)
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);
}
}
それと間違っている可能性がありますか?