服务端调用小程序http api 错误,hint: [qJgbH.wgE-PBg1lA]?
发布于 6 年前 作者 junzhang 11195 次浏览 来自 官方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 回复

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

回到顶部