I made this pull request to allow to use paged-request better.
I am using paged-request npm package on professional project to make a list of request. I need to pass a JWT authentication on header.
It is important to verify if JWT has expired before use it and this PR will allow to verify it or reauthenticate if it is needed.
I made a fix on tests before to refactor the main funcionality. The tests were breaking because regex to get next page number from html wasn't working.
These was the regex:
const regex = /href=".*?\/page\/(\d+)\/"/;
And this is the piece of html that is commig on response:
I made this pull request to allow to use paged-request better. I am using paged-request npm package on professional project to make a list of request. I need to pass a JWT authentication on header. It is important to verify if JWT has expired before use it and this PR will allow to verify it or reauthenticate if it is needed.
I made a fix on tests before to refactor the main funcionality. The tests were breaking because regex to get next page number from html wasn't working.
These was the regex:
And this is the piece of html that is commig on response:
As you don't have double quotes after href. Regex exec was returning nothing. The regex on test was changed to this:
Next. I started to refactor.
I changed opts to let so I can modify it after inside while:
And then the while loop is now as below:
Now you can authenticate before every request and make other important things on your project as needed.
I hope you can approve my work.
OBS: 7odri9o and rrodrigohenrique are the same person.