-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
End iteration for blank cursor #612
Comments
Can you point me to the docs or show an example? |
You can kinda see it in the example response here: https://api.slack.com/methods/admin.apps.requests.list I'll pull up specific examples when I'm back on my laptop. |
And this is where I clean it up: https://github.com/jonthegeek/slackapi/blob/main/R%2F040-pagination.R |
Given that you already have to write a function to extract it and this is a bit of a special case, I think your package is the right place for the code. I'd write it like this: .iterator_fn_cursor <- function() {
httr2::iterate_with_cursor(
"cursor",
resp_param_value = function(resp) {
cursor <- httr2::resp_body_json(resp)$response_metadata$next_cursor
fix_cursor(cursor)
}
)
}
fix_cursor <- function(x) {
if (identical(cursor, "")) {
NULL
} else {
cursor
}
} |
iterate_with_cursor()
checks that the next cursor is NULL. I've had to build in a check to convert empty strings""
toNULL
, for example for the Slack API. Would it be acceptable to build that into the default checker?https://github.com/r-lib/httr2/blob/main/R%2Fiterate-helpers.R#L100
The same idea likely also occurs for
iterate_with_link_url()
.The text was updated successfully, but these errors were encountered: