为了账号安全,请及时绑定邮箱和手机立即绑定

老师,请回答,VM868:1 SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse (<anonymous>) at comment.js:25

wx.cloud.callFunction({name:'getdetail',data:{movieid:options.movieid}}).then(res=>{console.log(res);this.setData({detail:JSON.parse(res.result)});wx.hideLoading();}).catch(err=>{console.error(err);wx.hideLoading();})

出错

VM868:1 SyntaxError: Unexpected token o in JSON at position 1

    at JSON.parse (<anonymous>)

    at comment.js:25


正在回答

2 回答

代码提供截图会更容易看出代码层次结构。

错误信息上看,是JSON.parse()的参数格式不对,请在控制台打印一下JSON.parse()的参数,看下值是什么,就能找到问题了。

1 回复 有任何疑惑可以回复我~

对的,谢谢老师,直接detail:res.result,去掉JSON.parse即可。

then(res=>{console.log(typeof(res.result));this.setData({detail:res.result});wx.hideLoading();})


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

老师,请回答,VM868:1 SyntaxError: Unexpected token o in JSON at position 1 at JSON.parse (<anonymous>) at comment.js:25

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号