>From the code sample and response provided, I am assuming the following:
- The javascript is running on the client side - gapi calls are essentially asynchronous XMLHttpRequest <https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest> s - .execute() methods take a callback function that will be invoked when the API call returns success or failure I believe the issue lies with how you may be handling asynchronicity. gapi calls are made asynchronously so that other javascript on the client can continue executing while the network request is made. For instance In the following example, the second console.log() will most likely be invoked first as the api call make take time to return. api.execute(function () { console.log('API response'); }); console.log('Second invocation'); If the second console.log() must be invoked after the first console.log(), it must be placed *within* the callback function like so: api.execute(function () { console.log('API response'); console.log('Second invocation'); }); With this in mind, if you must have a few gapi calls happen sequentially, the calls must be made from within each callback. For example, to sequentially execute authenticate, uploadImage, saveUser, this would have to be written somewhat like this: authenticate(currentUser).execute(function () { // authenticatation is done, proceed uploadImage(imageToSend).execute(function () { // image was uploaded saveUser(currentUser).execute(function () { // user was saved }); }); }); I hope this example is helpful for understanding the logic of asynchronous APIs and callbacks. For many gapi libraries, you may want to look at using Promises <https://developers.google.com/api-client-library/javascript/features/promises> to make this sort of logic somewhat clearer. On Wednesday, April 13, 2016 at 4:23:34 AM UTC-4, Juan Antonio Fernández Sánchez wrote: > > I have found a problem with GAE Cloud Endpoints when I try calling a > function and I need the result of this function to other call. > I know that I could resolve this problem to other way, but I want > understand how I can do this. > This is the summary, working in JavaScript. > I call to a gapi function to send an image to Server, when the process to > save finish, it return an url and i use this url to save the complete data > to user. > > The problem is that the users data always is saved before than the > response arrive and it is saved without url that I need because the second > call don't wait to first call. > > > I have tried to use callbacks and other tools but I don't find the way. > > Somebody had been the same problem? Thanks you. > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at https://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/3ad0a9a2-8e5b-4dda-91b2-20d2818d03ed%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.