You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with the usa-npn API which takes multiple values for a query like so: x[1]=1&x[2]=2&x[3]=3. The .multi argument doesn't seem to be able to handle this and I have to construct the list of queries outside of req_url_query(). It seems like there isn't a way for a function supplied to .multi to use the parameter name. E.g., this doesn't work:
library(httr2)
#this sort of thing would be nicefoo<-function(x) {
x_name<- deparse(substitute(x))
glue::glue("{x_name}[{seq_along(x)}]={x}") %>%
glue::glue_collapse(sep="&")
}
ID<-5:7
foo(ID)
#> ID[1]=5&ID[2]=6&ID[3]=7#but doesn't work here
request("https://example.com") %>%
req_url_query(
ID=5:7,
.multi=foo
)
#> <httr2_request>#> GET https://example.com?ID=X[[i]][1]=5&X[[i]][2]=6&X[[i]][3]=7#> Body: empty
Is there a workaround for this? I looked at the code to figure out what "explode" does, and it seems like it behaves differently from an anonymous function—I couldn't figure it out.
The text was updated successfully, but these errors were encountered:
I'm working with the usa-npn API which takes multiple values for a query like so:
x[1]=1&x[2]=2&x[3]=3
. The.multi
argument doesn't seem to be able to handle this and I have to construct the list of queries outside ofreq_url_query()
. It seems like there isn't a way for a function supplied to.multi
to use the parameter name. E.g., this doesn't work:Created on 2024-12-09 with reprex v2.1.1
Is there a workaround for this? I looked at the code to figure out what
"explode"
does, and it seems like it behaves differently from an anonymous function—I couldn't figure it out.The text was updated successfully, but these errors were encountered: