I am trying to paginate the result from the watson conversation api. But I am unable to do that.
I have tried creating a function where I pass the url of the next_page but it doesn't work.
function callWatson(url) {
let watson_url = 'https://gateway.watsonplatform.net/assistant/api';
if (!url) {
watson_url = `${watson_url}/v1/workspaces/[workspace_id]/logs?version=2018-09-20`;
} else {
watson_url = `${watson_url}/${url}`;
}
assistant = new watson.AssistantV1({
username: ************,
password: ************,
url: watson_url,
rejectUnauthorized: false,
version: '2018-09-20'
});
return assistant;
}
let input = [];
let pagination = [];
assistant.listAllLogs(param, function(err, response) {
if (err) {
console.error(err);
} else {
for (var i = 0; i < response.logs.length; i++) {
pagination.push(response.pagination);
input.push(response.logs[i]);
}
// logger.debug(input);
logger.debug(pagination);
}
});
Based on the docs you need to use "next_url" - The URL that will return the next page of results, if any.
您需要将当前响应中的pagination
对象中的next_cursor
字段作为后续请求中的cursor
参数的值进行传递。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.