Skip to content

Commit

Permalink
Merge pull request #8 from afosto/Fix/pagination-offset-hits-per-page
Browse files Browse the repository at this point in the history
Fix/pagination-offset-hits-per-page
  • Loading branch information
Rapid0o authored Jan 26, 2022
2 parents 3c3af62 + 1240774 commit e12f8eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@afosto/instant-search-client",
"version": "1.0.0",
"version": "1.0.1",
"private": false,
"description": "The Afosto InstantSearch client",
"main": "./dist/afosto-instant-search.min.js",
Expand Down
5 changes: 3 additions & 2 deletions src/adapters/SearchRequestAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ const SearchRequestAdapter = () => {
*/
const transformPagination = (request, options = {}) => {
const { page, hitsPerPage } = request?.params ?? {};
const offset = page * hitsPerPage;
const limit = hitsPerPage || options.hitsPerPage;
const offset = page * limit;

return { limit: hitsPerPage || options.hitsPerPage, offset };
return { limit, offset };
};

/**
Expand Down

0 comments on commit e12f8eb

Please sign in to comment.