我创作的API休息谷歌的文件夹的过程中收到未定义:
文件夹ID:未定义
下面我的代码:
var fileMetadata = {
'name': nameProduct,
'mimeType': 'application/vnd.google-apps.folder',
parents: XXXXXXXXXXXXXXXX
};
drive.files.create({
auth: jwToken,
resource: fileMetadata,
fields: 'id'
}, function (err, file) {
if (err) {
console.error(err);
} else {
console.log('Folder Id: ', file.id);
}
});
console.log("end creation folder");
我怎样才能打印file.id?谢谢
// Make sure the client is loaded and sign-in is complete before calling
gapi.client.drive.files.create({
"resource": {}
})
.then(function(response) {
// Handle the results here (response.result has the parsed body).
console.log("Response", response);
},
function(err) {
// handle error here.
console.error("Execute error", err); });
}
首先,你必须创建一个请求,然后等待里面的“然后”的响应。