Saturday 1 April 2017

ExpressJS - How to change the value of key in the url of a get request

So I am developing custom pagination functionality with express and mongoose. I have a get parameter called page and I need to change the value for every different page. The problem is that the way I do it it keeps appending "page" key-value pairs to the url like this "&page=1&page=1&page=1". That is because I don't simply change the value of "page" but I append the key-value pair each time like so:

currentPageUrl: req.originalUrl + '&page=' + currentPage

I need just to change the value of the "page" key. How can I accomplish this? Any advice, express helper function or custom solution would help a lot. Thanks in advance!



via Codearts

No comments:

Post a Comment