0

When a Google App Engine endpoint API is called immediately once the page is loaded, the following error is thrown. I need to wait for few seconds to call the API.

Then is same when the page is reloaded by some other means, say called from an other page etc.

I have tried adding a callback to call the API after few milliseconds $timeout(queryCallback, 100, false); The results are the same.

Is this a AngularJS error or resource load error? How to solve the error, please share your comments.

angular-1.2.16.min.js:89 TypeError: Cannot read property 'queryInfo' of undefined
  at h.$scope.queryInfoAll (controllers.js:641)
  at $scope.queryInfo (controllers.js:616)
  at angular-1.2.16.min.js:119
  at e (angular-1.2.16.min.js:37)
  at angular-1.2.16.min.js:40

controllers.js:641

gapi.client.database.queryInfo().execute(function (resp) { }

1 Answer 1

1

In looking at the Java endpoints example here, you use endpoints in javascript by initializing via a call to

<script src="https://apis.google.com/js/client.js?onload=init"></script>

...which calls the JS method named "init", which is a method name of your choosing. This is, however, a plain ole JS method that is unaware of the AngularJS lifecycle. In your init method, it seems you explicitly init your specific endpoint library, as in:

gapi.client.load(apiName, apiVersion, callback, apiRoot);

So, in your "run()", you may have to ask if "gapi" exists and defer until it is. You would then call "gapi.client.load()" with the callback function set.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes! that is the way I was also loading the client endpoints. I have modified the code to verify 'gapi' and client endpoint availability. If it is not available then I am calling 'gapi.client.load' with a callback. Thanks for the suggestion!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.