Open weberam2 opened 1 month ago
Hey, I looked around a little. openmeteo
uses httr
to do the API calls, which uses curl. I haven't used shinylive myself but per this comment there's more fundamental limitations on opening websockets in the WebAssembly sandbox. It might be possible to use the direct approach they mention, i.e.
query_url <- paste0(
'https://api.open-meteo.com/v1/forecast?latitude=',
click$lat,
'&longitude=',
click$lng,
'&daily=temperature_2m_max,precipitation_sum,wind_speed_10m_max'
)
response <- readLines(query_url, warn=FALSE) |> jsonlite::fromJSON()
If that works in shinylive I could look at tweaking the httr
calls to use the base methods instead -- the comment above also mentioned possible CORS issues.
Hi Tom,
Thanks for getting back to me. I tried your solution but no luck.
I simplified my code to figure out where the problem lies, and it seems like it is indeed readLines
So frustrating. I'll see if I can find any other workarounds...
Nevermind! That does work!
I must have introduced another bug somewhere, but I fixed it and your solution worked :smile:
Sorry if I am out of my depths here.
I built a ShinyR app that populates a map with Lon/Lat values. And I had it such that if you click on one of the icons, it would call openmeteo, download the forecast, then plot it using ggplot
The app works as expect; but when I convert it to an HTML using shinylive
shinylive::export(appdir = "../../ShinyRMap", destdir = "docs")
the HTML version doesn't workhttpuv::runStaticServer("docs")
I get two warning messages when I run shinylive:
I'm guessing it's the curl issue?
I'm happy to share the full code if that helps.
This is how I'm calling openmeteo: