【发布时间】:2020-06-13 13:08:13
【问题描述】:
每次登录 JSON 解析错误时都会出错:无法识别的令牌 '
导出默认类表单扩展组件{
>constructor(props) {
> super(props)
> this.state = { email1: '', password1: '' } }
>
> login = () => {
> const { email1 } = this.state;
> const { password1 } = this.state;
>
> fetch('http://192.168.1.114/login.php',{
> method: 'POST',
> headers:{
> 'Accept': 'application/json',
> 'Content-Type':'application/json'
> },
> body: JSON.stringify({
> email: 'email1',
> password: 'password1'
> })
> })
>
> .then((response) => response.json()) .then((responseJson) =>{
> alert(responseJson); }) .catch((error)=>{
> console.error(error); });
>
> };
【问题讨论】:
-
这只是意味着 HTTP 响应不是 JSON。我们无法从您提供的代码中判断它是什么。
标签: react-native