Last active
November 16, 2016 14:02
-
-
Save ryasmi/0d3489ae058b91a52dd3ad380a98982e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
injectScript = (src) => { | |
return new Promise((resolve) => { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.async = true; | |
script.src = src; | |
script.onload = () => resolve(window.gapi); | |
document.body.appendChild(script); | |
}); | |
}; | |
googleClientScriptSrc = 'https://apis.google.com/js/client.js'; | |
promise = injectScript(googleClientScriptSrc); | |
promise.then((gapi) => { | |
// Do stuff with `gapi`. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment