繁体   English   中英

我正在使用Ionic并收到错误消息:SyntaxError:JSON中的意外标记&lt;在JSON.parse位置0处( <anonymous> )

[英]I am using ionic and getting an error: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>)

这是我的代码:

this.http.get('http://localhost/....)

      .map((res) => res.json())

      .subscribe((

        this.navCtrl.push(OtpPage,{mobileno:this.mobile});

      }, (err) => {
        console.log(err);
      });

并得到以下错误:

SyntaxError:JSON中的意外令牌<位于JSON.parse()的位置0

任何人都可以帮忙吗?

如@Protectator所述,您从服务器返回的响应不是有效的JSON,并且当代码尝试调用res.json()时,它将引发错误。

通过删除/更新以下代码段来尝试。

.map((res))

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM