Searches the Media Manager and returns a list of folders that match the terms specified in the parameters.
The searchFolders()
function returns a Promise that resolves to information about the specified folders and cursor information.
If no parameters are specified, the function returns all folders in the MEDIA_ROOT
folder.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function searchFolders(
options: SearchFoldersOptions,
): Promise<SearchFoldersResponse>;
Options specifying which folders to search.
import { folders } from "wix-media.v2";
async function mySearchFoldersFunction() {
try {
const foldersFound = await folders.searchFolders();
console.log("Folders found in search:", foldersFound);
return foldersFound;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "folders": [
* {
* "_createdDate": "2023-08-14T07:41:19.000Z",
* "_id": "103601562ec94214bee61f470b403dd5",
* "_updatedDate": "2023-08-21T11:09:08.000Z",
* "displayName": "Pictures",
* "parentFolderId": "media-root",
* "state": "OK"
* },
* {
* "_createdDate": "2023-08-21T05:34:03.000Z",
* "_id": "302fc049d70c41dea33fa4a27ab481ba",
* "_updatedDate": "2023-08-21T05:34:03.000Z",
* "displayName": "Videos",
* "parentFolderId": "media-root",
* "state": "OK"
* }
* ],
* "nextCursor": {
* "cursors": {
* "next": ""
* },
* "hasNext": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.