简体   繁体   English

SyntaxError:JSON.parse:JSON数据第1行第1列的数据意外结束[了解更多]

[英]SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data[Learn More]

Please a I cann't solve this problem, someone can help me? 请一个我不能解决这个问题,有人可以帮助我吗?

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);
 })
}

ERROR: 错误:

在此处输入图片说明

postman: 邮差:

在此处输入图片说明

I think there is problem with your body object.Because you are passing only value to body without key. 我认为您的身体对象存在问题,因为您只是将价值传递给身体而没有钥匙。 so body should be body: JSON.stringify({email:email, password:senha}) 因此主体应为body: JSON.stringify({email:email, password:senha})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SyntaxError:JSON.parse:JSON数据第3行第1列的意外字符 - SyntaxError: JSON.parse: unexpected character at line 3 column 1 of the JSON data SyntaxError:JSON.parse:JSON数据的第1行第2列出现意外字符 - SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data SyntaxError:JSON.parse:JSON数据的第1行第1列出现意外字符吗? - SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data? 语法错误json.parse json数据第1行第1列的意外字符 - syntaxerror json.parse unexpected character at line 1 column 1 of the json data 语法错误:JSON.parse:JSON 数据的第 1 行第 1 列出现意外字符 - SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data React SyntaxError:JSON.parse:JSON 数据第 1 行第 1 列的数据意外结束 - React SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data SyntaxError: JSON.parse: JSON 数据第 1 行第 1 列的数据意外结束 OK - SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK Javascript 错误:SyntaxError: JSON.parse: JSON 数据第 1 行第 1 列的数据意外结束 - Javascript error: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data 调用其余的WS并获取:SyntaxError:JSON.parse:JSON数据第1行第1列的数据意外结束 - Call a rest WS and get: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data SyntaxError: JSON.parse: JSON 数据的第 1 行第 1 列的数据意外结束,使用 fetch - SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data using fetch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM