请求腾讯云后台无法返回数据
发布于 5 年前 作者 jie53 4691 次浏览 来自 问答

小程序向后台请求数据


后台代码

ctx.state.data = {

    msg: 'token'

}

前端能得到  msg:'token'


后台要是发起一个api请求

request({

    method: 'GET',

    url: tokenUrl

    }, function (err, res, body) {

        if (res) {

            token = JSON.parse(body);

            ctx.state.data = {

                msg: token

            }

    }

})

前端就无法获取数据


这是因为什么?


前端代码

qcloud.request({

    url: config.service.qrcodeUrl,

    login: true,

    success(result) {

        that.setData({

        wxToken:result.data

        })

        console.log(result.data)

        util.showSuccess('请求成功')

        //console.log()

    },

    fail(error) {

        util.showModel('请求失败', error)

        console.log('request fail', error)

    }

})

1 回复

什么原因?

回到顶部