Created
August 28, 2019 07:19
-
-
Save robertour/43364940c2a3b9f528ec6c987a19fa21 to your computer and use it in GitHub Desktop.
creates a binder session on the background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch = function() { | |
// URL of the repository | |
var apiUrl = 'https://notebooks.gesis.org/binder/build/gh/gesiscss/smm_demo/master'; | |
eventSource = new EventSource(apiUrl); | |
eventSource.onerror = function(err) { | |
console.error("Failed to construct event stream", err); | |
}; | |
eventSource.addEventListener("message", function(event) { | |
var data = JSON.parse(event.data); | |
if (data.phase == 'ready') { | |
// data['url'] and data['token'] are both required to assemble the URL | |
console.log(data['url'] + '?token=' + data['token']); | |
eventSource.close(); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment