Returns the documents that match the search.
The find()
function returns a Promise that resolves to the results found
by the search and some information about the results. The Promise is
rejected if any of the functions used to refine the search are invalid.
If you build a search and don't refine it with any WixSearchBuilder
functions,
find()
returns all matching site documents.
function find(): Promise<WixSearchResult>;
This example demonstrates how to run a find()
on a search()
that was previously built and stored in a variable.
search
.find()
.then((results) => {
if (results.documents.length > 0) {
let documents = results.documents;
} else {
console.log("No matching results");
}
})
.catch((error) => {
console.log(error);
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.