[英]SyntaxError: JSON.parse: unexpected character at line 3 column 1 of the JSON data
[英]SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data[Learn More]
请一个我不能解决这个问题,有人可以帮助我吗?
handleSubmit = event => {
event.preventDefault();
const email = document.querySelector(".email").value;
const senha = document.querySelector(".password").value;
alert(JSON.stringify({email, senha}));
const res = {
method: 'POST',
mode:'no-cors',
body: JSON.stringify({email,senha}),
headers: new Headers({
'Content-type': 'application/json',
'Authorization': 'Token Here',
}),
};
fetch('http://rhvagas-api/login', res).then(res => res.json())
.then(result => {
console.log(result);
})
}
错误:
邮差:
我认为您的身体对象存在问题,因为您只是将价值传递给身体而没有钥匙。 因此主体应为body: JSON.stringify({email:email, password:senha})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.