0
I have the following code:
var rtn = null;
gapi.client.drive.files.list({
q: "mimeType = 'application/vnd.google-apps.folder'",
}).then(function(response) {
var files = response.result.files;
rtn = files[0]["id"];
});
console.log(rtn);
The variable files
is not empty, I have tried several ways to pass its value, or use a return
, however rtn
continues as null
, I also tried to:
var rtn = {};
gapi.client.drive.files.list({
q: "mimeType = 'application/vnd.google-apps.folder' and name = '"+name+"' and '1zo-0IG0d7v91P25Ln6haxF2isMbt0hN8' in parents",
}).then(function(response) {
var files = response.result.files;
rtn.file = files[0]["id"];
});
And by giving a console.log(rtn)
outside the function, there is rtn.file
with the supposed value, but when I call directly the same with rtn.file
, says it’s undefined
, what is happening and how I can solve the problem?
of the one
console.log(response)
inside the function to see– Wees Smith