Utilizing the Google Drive API for JavaScript within a VueJS application can be done as follows:
In your index.html
<script type="text/javascript">
window.___gcfg = {
parsetags: 'explicit',
lang: 'en-US'
};
</script>
<script src='https://apis.google.com/js/platform.js' async defer></script>
Within a component:
export default {
mounted() {
window.gapi.savetodrive.go(`savetodrive-${this.id}`);
},
}
The "Save to Drive" buttons are displayed correctly, but upon navigating away from the component (when the HTML element is removed from the DOM), multiple exceptions are thrown in the console:
Uncaught DOMException: Blocked a frame with origin "https://drive.google.com" from accessing a cross-origin frame.
at Object.nz [as kq] (https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.xh-S9KbEGSE.O/m=gapi_iframes,gapi_iframes_style_common/rt=j/sv=1/d=1/ed=1/am=wQc/rs=AGLTcCNaUSRWzhd71dAsiMVOstVE3KcJZw/cb=gapi.loaded_0:150:257)
at jz.send (https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.xh-S9KbEGSE.O/m=gapi_iframes,gapi_iframes_style_common/rt=j/sv=1/d=1/ed=1/am=wQc/rs=AGLTcCNaUSRWzhd71dAsiMVOstVE3KcJZw/cb=gapi.loaded_0:148:261)
at Fz (https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.xh-S9KbEGSE.O/m=gapi_iframes,gapi_iframes_style_common/rt=j/sv=1/d=1/ed=1/am=wQc/rs=AGLTcCNaUSRWzhd71dAsiMVOstVE3KcJZw/cb=gapi.loaded_0:152:349)
at https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.xh-S9KbEGSE.O/m=gapi_iframes,gapi_iframes_style_common/rt=j/sv=1/d=1/ed=1/am=wQc/rs=AGLTcCNaUSRWzhd71dAsiMVOstVE3KcJZw/cb=gapi.loaded_0:152:259
Am I overlooking something? Is there another step I need to follow when destroying the view?
Please note that the file path for the button is on the same server and specified as relative, so CORS is not an issue for downloading the file. Everything works fine except for the JavaScript errors being triggered.