Search.../

prev( )

Retrieves the previous page of search results.

Description

The prev() function retrieves the previous page of search results.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

If items are added or removed between calls to prev() the values returned may change.

Syntax

function prev(): Promise<WixSearchResult>

prev Parameters

This function does not take any parameters.

Returns

Fulfilled - A search result object with the previous page of search results. Rejected - The errors that caused the rejection.

Return Type:

Was this helpful?

Get the previous page of a search result

Copy Code
1oldResults.prev()
2 .then( (results) => {
3 let newResults = results;
4 let documents = newResults.documents;
5 let firstDocument = documents[0];
6 let facets = results.facets;
7 let totalCount = newResults.totalCount;
8 let pageSize = newResults.pageSize;
9 let currentPage = newResults.currentPage;
10 let totalPages = newResults.totalPages;
11 let hasNext = newResults.hasNext();
12 let hasPrev = newResults.hasPrev();
13 let length = newResults.length;
14 } )
15 .catch( (error) => {
16 console.log(error);
17 } );