Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:55:59+00:00 2026-05-25T17:55:59+00:00

I am trying to do some simple pagination. To that end, I’m trying to

  • 0

I am trying to do some simple pagination.
To that end, I’m trying to parse the current URL, then produce links to the same query, but with incremented and decremented page parameters.

I’ve tried doing the following, but it produces the same link, without the new page parameter.

var parts = url.parse(req.url, true);
parts.query['page'] = 25;
console.log("Link: ", url.format(parts));

The documentation for the URL module seems to suggest that format is what I need but I’m doing something wrong.

I know I could iterate and build up the string manually, but I was hoping there’s an existing method for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:56:00+00:00Added an answer on May 25, 2026 at 5:56 pm

    If you look at the latest documentation, you can see that url.format behaves in the following way:

    • search will be used in place of query
    • query (object; see querystring) will only be used if search is absent.

    And when you modify query, search remains unchanged and it uses it. So to force it to use query, simply remove search from the object:

    var url = require("url");
    var parts = url.parse("http://test.com?page=25&foo=bar", true);
    parts.query.page++;
    delete parts.search;
    console.log(url.format(parts)); //http://test.com/?page=26&foo=bar
    

    Make sure you’re always reading the latest version of the documentation, this will save you a lot of trouble.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to find some simple SQL Server PIVOT examples. Most of the examples that
i was trying to do some simple text formatting using JEditorPane but then as
Hello I am trying to create some simple pagination, but my php skills are
I'm trying to implement some simple paging, based on How do I do pagination
I'm trying to write some simple code that will return the directory for the
I'm trying to write some simple C# code that will select some data from
I'm trying to find some simple way of queueing tasks on a thread that
I am trying to do some simple formatting stuff with 'sed' in linux, and
I was trying to place some simple effects on an image using HBox using
I am trying to create some simple polygons in openGL3.3. I have 2 types

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.