Reputation: 85
I am trying to open the folder and see the files inside
const children = await axios.get(
`https://www.googleapis.com/drive/v3/files/${folder.id}`,
{
params: {
fields: "files(id, name)",
spaces: "drive",
},
headers: {
authorization: `Bearer ${accessToken}`,
},
}
);
can we open sub folder using folder id? i tried it but it show errors
Upvotes: 1
Views: 507
Reputation: 1224
As google drive doc uses q parameter to get a list of files inside a folder
q:"'{FolderID}' in parents"
so your Axios get request will be like that
const emptyFoldersSearch2 = await axios.get(
"https://www.googleapis.com/drive/v3/files",
{
params: {
q:"'1VwXsYxTTGid9GIYHzkzD7LPFN5bRUSKD' in parents" ,
},
headers: {
authorization: `Bearer ${accessToken}`,
},
}
);
Upvotes: 1
Reputation: 116948
Check the q pram search opperators with file.list it will let you list the files with in a folder
q=parents%20in%20%27root%27
Or
curl \
'https://www.googleapis.com/drive/v3/files?q=parents%20in%20%27root%27&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Upvotes: 2