Skip to content
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

Pause execution if request limit reached #123

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: locateip
Title: Locate IP Addresses with 'ip-api'
Version: 0.1.3
Version: 0.1.3.9000
Authors@R:
person("Judith", "Bourque", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0009-0000-3653-1530"))
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# locateip (development version)

# locateip 0.1.3

* Added a `NEWS.md` file to track changes to the package.
Expand Down
5 changes: 5 additions & 0 deletions R/locate.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ get_location <-
resp <- create_req(ip = ip, fields = fields, lang = lang, header = header, ..., format = format) |>
httr2::req_perform()

# If there's no remaining requests, pause execution
if (as.numeric(httr2::resp_header(resp, "X-Rl")) == 0) {
Sys.sleep(as.numeric(httr2::resp_header(resp, "X-Ttl")))
}

return(resp)
}

Expand Down