I'm not sure I understand what you are trying to do. I would advise to read on R scoping.
Here is something that could inspire you, maybe?
library(plumber)
states <- new.env()
trial_query<- function(msg = "") {
states$msg <- msg
list(msg = paste0("The message is: '", msg, "'"))
}
abc <- function(){
list(msg = paste0("The message is: '", states$msg, "'"))
}
#* @get /echo
trial_query
#* @get /calling
abc
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…