服务端调用小程序http api 错误,hint: [qJgbH.wgE-PBg1lA]?

发布于 7 年前作者 junzhang11373 次浏览最后编辑 7 年前来自 issues

服务端调用小程序http api 发现过滤的语句不能使用变量,比如

let data = {key: '2020-03-21'};

return rp({
            url`https://api.weixin.qq.com/tcb/databasequery?access_token=${token}`,
            method"POST",
            jsontrue,
            headers: {
                "content-type""application/json",
            },
            body: {
                "env":"any-id",
                "query"`db.collection(\"all_houses\").where(${data}).get()`
            }
        }).then((res)=>{
            console.log("res: %O", res);
            return res;
        }).catch(err=>{
            console.log("err: %O", err);
        })

如果不使用变量就不会有错,比如这样

return rp({
            url`https://api.weixin.qq.com/tcb/databasequery?access_token=${token}`,
            method"POST",
            jsontrue,
            headers: {
                "content-type""application/json",
            },
            body: {
                "env":"any-id",
                "query"`db.collection(\"all_houses\").where({key: '2020-03-12'}).get()`
            }
        }).then((res)=>{
            console.log("res: %O", res);
            return res;
        }).catch(err=>{
            console.log("err: %O", err);
        })

1 回复
kfan
kfan1 楼5 年前

对你很无语,不会排查问题,做事不认真