fknop / hapi-pagination

Hapi plugin to handle "custom" pagination
MIT License
63 stars 35 forks source link

Metadata not included in response headers when the total count <= limit #68

Closed BrandonNoad closed 4 years ago

BrandonNoad commented 6 years ago

If meta.location === 'header' and the total count is less than or equal to the limit, then the pagination metadata is not included in the response headers.

Here is the code controlling this behaviour (from lib/ext.js):

if (this.config.meta.location === 'header') {
    delete request.response.headers['total-count'];

    if (totalCount > currentLimit && results.length > 0) {
        // put metadata in headers rather than in body

If you remove the totalCount > currentLimit restriction, then the response headers have the pagination metadata and there doesn't appear to be any errors.

Is the current behaviour intended?

peveuve commented 5 years ago

Too late, but yes it is by design, we do not send the pagination metadata if there is only one page (not paginated in other words)