I'm using MongoDB Stitch within my Shiny application, and to use my query function, I need to import the Stitch export from the MongoDB Stitch JavaScript SDK. The following is parsed with no issues locally using extendShinyjs:
library(shiny)
library(shinyjs)
jsCode <- '
shinyjs.init = function() {
const {
Stitch
} = stitch;
window.stitchClient = Stitch.initializeDefaultAppClient("xxx");
}'
shinyApp(
ui = fluidPage(
tags$head(HTML('<script src="https://s3.amazonaws.com/stitch-sdks/js/bundles/4.9.0/stitch.js"></script>')),
useShinyjs(),
extendShinyjs(text = jsCode)
),
server = function(input, output) {
}
)
However, I get the following error when the above code is called by extendShinyjs in the shiny server: shinyjs: Error parsing the JavaScript code provided. I've confirmed through repeated tests that the issue is through my calling the Stitch export with the first command of the shinyjs.init function. Not sure if there's a work around this. Thanks for your help!