问题
I have two Shiny apps that I'm working on, and I'd like to be able to use App 1 to generate some input to App 2(in this case a gene name). The gene name from App 1 is parsed via shiny
's parseQueryString()
, and then does whatever in regards to App 2.
To simulate App 1, I just have a simple HTML file(I got the link structure from this webinar about bookmarking):
<html>
<body>
<div>
<a href="http://10.59.24.60:3800/quux/?_inputs_&gene=IL23R">Send to targetProfiler</a>
</div>
</body>
</html>
Where "quux" is the name of App 2. This works perfectly fine; I click the link and am brought to App 2, and then it searches for the gene name in a database, etc. However, I get a shiny
error message in the bottom right corner
in which it reads that shiny
thinks it failed to parse the URL param, when in fact it did.
The server code that handles this is set up like this:
observe({
#make sure its first time loading app
if (!vals$firstLoad) {
return (NULL)
}
query <- parseQueryString(session$clientData$url_search)
# browser()
# Only continues when there is gene names to be queried in the URL
req(query[['gene']])
# Get URL parameter
inputText <- paste0(unique(splitByComma(query[['gene']])), collapse = ',') # Only unique terms
#do stuff with inputText
#...
#...
Is there a way to suppress this warning/error? Or what is being done wrong that shiny
thinks that it hasn't properly parsed the URL parameter, when in fact it has?
回答1:
Bookmarked values are encoded in a URL as JSON. IL23R
isn't a valid JSON string without double quotes. gene="IL23R"
should work, or also percent-encoded like gene=%22IL23R%22
.
来源:https://stackoverflow.com/questions/47536690/r-shiny-app-load-from-link-throws-restorecontext-error-yet-still-works