Retrieve the contents
of a directory by its ID. This method is useful when you want to list the directories and files within a specific directory.
try {
const id = 'directory_id_here' // Replace with the desired directory ID
const [data, error] = await sdk.directory.contents({ id })
const { directories, files } = data
// Check for success
if (error) {
console.error('Failed to get directory contents: ', error);
} else {
console.log('Directories:')
directories.forEach((directory) => {
console.log(directory)
})
console.log('Files:')
files.forEach((file) => {
console.log(file)
})
}
} catch (error) {
console.error(error.message)
}
Params
id
(string): The ID of the directory you want to retrieve. If not provided, it retrieves the root directory.
Required API Key Permission
Read Directory