Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the totalCount by adding the totalCount to the request object - Use request.plugins #53

Open
BrandonNoad opened this issue Jun 28, 2017 · 0 comments

Comments

@BrandonNoad
Copy link

BrandonNoad commented Jun 28, 2017

In the current implementation, the totalCount is set directly on the request object:

request.totalCount = 10;
reply(results);

Hapi recommends that you use the 'plugins' property to store plugin-specific state. From the docs:

Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state.

So it would be better to do:

request.plugins['hapi-pagination'] = {
    totalCount: 10
};
reply(results);

Although this would be a breaking change, it is a safe place to store plugin data without potential conflicts with the framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant