This sort of reactiveValues() and observe() pattern is really only necessary for maintaining state that isn't explicitly captured by input values.
For this application, you don't really need to do that, so I'd recommend chaining reactive() together. Also, note that reactive() should always return a value, and never be used to perform side effects (i.e., modify another reactiveValues()). On the other hand, observe() is designed for performing side-effects and should never return a value.
server <- function(input, output) {
day_ <- reactive({
ifelse(
nchar(day(as.character(input$date))) == 1,
paste0("0", day(as.character(input$date))),
day(as.character(input$date))
)
})
month_ <- reactive({
ifelse(
nchar(month(as.character(input$date))) == 1,
paste0("0", month(as.character(input$date))),
month(as.character(input$date))
)
})
url <- reactive({
glue("https://api.abalin.net/get/namedays?day={day_()}&month={month_()}")
})
result <- reactive ({
r <- GET(url())
r_content <- content(r, "text", encoding = "ISO-8859-1")
r_json <- jsonlite::fromJSON(r_content, flatten = TRUE)
cbind(us=r_json$data$name_us,cz= r_json$data$name_cz, sk=r_json$data$name_sk )
})
output$table_names <- DT::renderDataTable({
result()
})
}
shinyApp(ui = ui, server = server)