Assign a column from dynamical API calls to a new list within a shiny app

Within a shiny app i have a reactive data frame which calls an API every 10 seconds. Every time the API is called and the new data frame is initialized with new data i want the abv column to be stored into a new list

beer = reactive({
        beer = jsonlite::fromJSON("", flatten = T) %>%
            tibble() %>% 
            select(name, abv, description)

This list must somehow be also reactive and be updated every time an API call is received. I basically want end up with a list from which i can plot the different values for abv i get from the consecutive API calls. How would i do this?

ui <- fluidPage(

server <- function(input, output, session) {
  abvlist <- reactiveVal(NULL)
  beer = reactive({
    new <- jsonlite::fromJSON("", flatten = T) %>%
      tibble() %>% 
      select(name, abv, description)
  output$beert <- renderTable({
  output$myplot <- renderPlot({
     abv <- req(abvlist())
shinyApp(ui, server)

This is doing the job, thank you!
But its not really clear to me why u sign the fromJSON call to a new variable. The code would also run without initializing a variabel called new

I agree,
it would allow further manipulations on new, if needed but in the current form is redundant.
You had similar set up in your own example ...

I see, for further manipulations it definitely would make sense.
I had that setup since i was experimenting a little, but it turns out, it isnt necessary for this urpose : )

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.