javascript - google cloud endpoints discrepancy between documentation, and what works in my app -
the documentation states should load api javascript this:
var root = 'https://your_app_id.appspot.com/_ah/api'; gapi.client.load('your_app_id', 'v1', function() { dosomethingafterloading(); }, root); but, seems is
var root = 'https://your_app_id.appspot.com/_ah/api'; gapi.client.load('your_api_name', 'v1', function() { dosomethingafterloading(); }, root); for example, can pass "users" api name, , users object defined attribute of gapi.client.
just clear, api defined this:
@endpoints.api(name='users',version='v1', description='the user service.') class userservice(remote.service): ... so now, wonder, doing in unintended way? and, since /_ah/api/explorer can find apis defined, there way have function add apis define without having specify names in separate gapi.client.load calls?
thanks pointing out, bug in documentation! we'll try if fixed asap.
you should check out fully-baked tic tac toe sample application.
in it, show how load multiple apis (among other things).
google.devrel.samples.ttt.init = function(apiroot) { // loads oauth , tic tac toe apis asynchronously, , triggers login // when have completed. var apistoload; var callback = function() { if (--apistoload == 0) { google.devrel.samples.ttt.signin(true, google.devrel.samples.ttt.userauthed); } } apistoload = 2; // must match number of calls gapi.client.load() gapi.client.load('tictactoe', 'v1', callback, apiroot); gapi.client.load('oauth2', 'v2', callback); var buttons = document.queryselectorall('td'); (var = 0; < buttons.length; i++) { var button = buttons[i]; button.addeventlistener('click', google.devrel.samples.ttt.clicksquare); } var reset = document.queryselector('#restartbutton'); reset.addeventlistener('click', google.devrel.samples.ttt.resetgame); };
Comments
Post a Comment