title: R: Error in file(con, "r") : cannot open the connection
body: <p>i'm trying to run a API request for a number of parameters with the lapply function in R.</p>
  
  <p>However, when i run this function, i get the error " Error in file(con, "r") : cannot open the connection"</p>
  
  <p>Google suggests using setInternet2(TRUE) to fix this issue, however, i get the error: Error: 'setInternet2' is defunct.
  See help("Defunct"</p>
  
  <pre><code>localisedDestinationNameForGivenLang &lt;- function (LocationId) {
   gaiaURL &lt;- paste0("https://URL/",LocationId, "?geoVersion=rwg&amp;lcid=", "1036", 
  "&amp;cid=geo&amp;apk=explorer")
   print(LocationId)
   localisation &lt;- fromJSON(gaiaURL)
  }
  
  lapply(uniqueLocationId, localisedDestinationNameForGivenLang)
  </code></pre>
  
  <p>Can someone suggest a fix please?</p>