I'm using drive v3 of google drive api, and I want google files name, id, mimeType and md5Checksum.
/** serarch files from google
* @param query
* @returns {Promise} with the result of the search
*
*/
async search(query, token) {
const config = {
headers: {
Authorization: `Bearer ${token}`,
},
params: {
q: `name contains '${query}' and trashed=false and mimeType != 'application/vnd.google-apps.shortcut' and mimeType != 'application/vnd.google-apps.folder'`,
fields: '*',
spaces: 'drive',
pageSize: 13,
},
};
if(query.length === 0 || !token) return [];
const result = [];
try {
const response = await axios.get(
`https://www.googleapis.com/drive/v3/files`,
config
);
const files = await response.data.files;
if (files.length) {
files.map(file => {
let googleObject = {};
googleObject.id = file.id;
googleObject.name = file.name;
googleObject.icon = file.iconLink;
googleObject.mimeType = file.mimeType;
googleObject.md5Checksum = file.md5Checksum;
result.push(googleObject);
});
} else {
result.push({
id: '',
name: 'No results',
icon: 'my-icon',
mimeType: '',
});
}
return JSON.stringify(result);
} catch (error) {
console.log('error ', error);
return null;
}
}
So i get a response from the server, something like this :
{
"id": "****",
"name": "test"
"icon": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet",
"mimeType": "application/vnd.google-apps.spreadsheet"
}
I can't figure out what I'm doing wrong, I try to replace fields: 'files(id,name,mimeType,iconLink,md5Checksum)', with fields: '',* but i still have the same error (only id, name, mimetype and icon)