请求中指定的延续令牌格式错误

时间:2017-11-07 19:29:58

标签: javascript node.js pagination azure-cosmosdb

我真的很难尝试使用节点SDK与documentDB进行分页。

这就是我所拥有的:

find: function (querySpec) {
        var self = this;
        return new Promise((resolve, reject) => {
            var options = {
                maxItemCount: 2
            }
            var query = self.client.queryDocuments(self.collection._self, querySpec, options);
            query.executeNext(function (err, results, headers) {
                if (err) {
                    reject(err);
                } else {
                    self.continuation = headers['x-ms-continuation'];
                    resolve({ 'results': results, 'resource': headers['x-ms-resource-usage'] });
                }
            })
        });
    },


nextPage: function () {
        var self = this;
        console.log(this.continuation)
        return new Promise((resolve, reject) => {
            var options = {
                maxItemCount: 2
            }
            self.continuation ? options['continuation'] = self.continuation : '';
            var query = self.client.readDocuments(self.collection._self, options);
            query.executeNext(function (err, results, headers) {
                if (err) {
                    reject(err);
                } else {
                    resolve({ 'results': results, 'resource': headers['x-ms-resource-usage'] });
                }
            })
        });
    }

续订令牌: {"token":"-RID:K0JYAKIH9QADAAAAAAAAAA==#RT:1#TRC:2","range":{"min":"","max":"FF"}}

返回错误: { code: 400, body: '{"code":"BadRequest","message":"Message: {\\"Errors\\":[\\"The continuation token specified in the request is malformed. Please re-run the query without it and iterate.\\"]}\\r\\nActivityId: 9e04278a-3808-4a59-8e63-dae191ef3519, Request URI: ...."}', activityId: '9e04278a-3808-4a59-8e63-dae191ef3519' }

所以基本上我正在加载限制为2项的页面。然后对于下一页我发送延续令牌,但我收回错误格式错误令牌。

我做错了什么?

0 个答案:

没有答案