Allow API Key declaration after import
According to http://developer.recursivelabs.io/index.html you can embed the API by either declaring it as a script:
<script src="https://embed.rcrsv.io/{token}"></script>
Or
var rcrsvEmbedScript = document.createElement('script');
document.body.appendChild(rcrsvEmbedScript);
rcrsvEmbedScript.setAttribute('src', 'https://embed.rcrsv.io/{token}');
However, since:
"The embed loads the RcrsvAPI functionality asynchronously - you will not be able to access API functions immediately following the inclusion of the embed code. Your application can be notified of the API's availability using RcrsvEmbed.onload."
RcrsvEmbed.onload(function (err) {
if (err) {
//an error occurred - RcrsvAPI did not load
} else {
//RcrsvAPI is ready to use
}
});
This doesn't work with the second option as RcrsvEmbed hasn't been initialized yet.
It would be beneficial to be able to import a RcrsvEmbed object synchronously and authenticate it with an API call, such as `RcrsvEmbed.setAPIKey(*token*)`, and then you could define the callbacks with `RcrsvEmbed.onload()`
Please sign in to leave a comment.
Comments
0 comments