title: R Shiny get IP adress return from asynchronous call javascript
body: <p>I am trying to get client IP adress using javascript on my R Shiny App. <code>alert</code> print the right result, function is working in <code>javascript</code> as stand alone but the return is <code>NULL</code> in R.</p>
  
  <p>I suspect that the problem is an asynchronous call that does not wait to return immediately because <code>alert</code> provides the right result. I tried to modifiy my javascript to get it synchronous but still get the same result.</p>
  
  <p>An other way to get IP adress in R might be accepted.</p>
  
  <p>File <code>app.R</code>:</p>
  
  <pre><code>library(shiny)
  library(shinyjs)
  
  ui &lt;- function(req) {
    fluidPage(
      useShinyjs(),
      extendShinyjs(text = "
      shinyjs.getIP = function(){
        $.getJSON('https://ipapi.co/json/').then(function(data){
          alert(JSON.stringify(data.ip, null, 2));
          return JSON.stringify(data.ip, null, 2);
        });
      }
  
      shinyjs.getIP2 = function(){    
        var jqxhr = $.getJSON('https://ipapi.co/json/');
        jqxhr.done(function(data) {
          alert(JSON.stringify(data.ip, null, 2));
          return JSON.stringify(data.ip, null, 2);
        });
      }
      ")
    )
  }
  
  server &lt;- function(input, output, session) {
    ip &lt;- reactive(js$getIP())
  
    observe({
      print(ip())
    })
  
    ip2 &lt;- reactive(js$getIP2())
  
    observe({
      print(ip2())
    })
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>