ngGAPI
ngGAPI copied to clipboard
Unable to call init() on GAPI
Hi, I can't seem to initialize GAPI and I'm not sure why. I get this error message:
TypeError: Cannot read property 'authorize' of undefined at Function.GAPI.init (gapi.js:404) at new
(main.min.js:303) at invoke (angular.js:3720) at Object.instantiate (angular.js:3731) at angular.js:6848 at q (angular-ui-router.min.js:7) at A (angular-ui-router.min.js:7) at Scope.$broadcast (angular.js:12329) at t.transition.N.then.t.transition.t.transition (angular-ui-router.min.js:7) at wrappedCallback (angular.js:11033)
Here's the code from my controller:
routerApp.controller('home-controller', function($scope, GAPI, Calendar) { //debugger; GAPI.init(); var cal = Calendar.getCalendars('[email protected]');
I'm not sure if this is a bug or if I'm missing something obvious 😳.
Thanks! Alistair
Same here.
I don't know exactly why this is happening, but the client id is not recognised by the library so you have to add the client id on google client library load
This works for me:
<script src="https://apis.google.com/js/client.js?onload=onClientLoad"></script>
and then in the function:
function onClientLoad(){ gapi.client.load('calendar', 'v3', function(){ gapi.client.setApiKey('YOUR_CLIENT_ID_HERE }); }
Hope this helps.