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

How to get search params in custom routes #2100

Open
slimes28 opened this issue Apr 25, 2024 · 6 comments
Open

How to get search params in custom routes #2100

slimes28 opened this issue Apr 25, 2024 · 6 comments
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity enhancement M-T: A feature request for new functionality good first issue Good for newcomers question M-T: User needs support to use the project semver:minor
Milestone

Comments

@slimes28
Copy link

Hello,
Is this the only option to get search params in custom router or there is a better way?
#1325 (comment)

@WilliamBergamin
Copy link
Contributor

Hi @slimes28
The following seems to be the simplest way to collect search params, the Bolt framework is tailored to interact with the Slack API which rarely uses these parameters

let urlParams: URLSearchParams = new URLSearchParams();
const params = req.url.split("?");
if (params.length > 1) {
  urlParams = new URLSearchParams(params[1]);
}

@WilliamBergamin WilliamBergamin added question M-T: User needs support to use the project and removed untriaged labels Apr 25, 2024
@zimeg
Copy link
Member

zimeg commented Apr 26, 2024

🤔 Wondering if we might want to treat this as a possible enhancement such that these params can be accessed from the request object?

https://localhost:3000/greetings?name=you
const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  customRoutes: [
    {
      path: '/greetings',
      method: ['GET'],
      handler: (req, res) => {
        res.writeHead(200);
        res.end(`Hello ${req.query.name}!`);  // Hello you!
      },
    },
  ],
});

Copy link

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

@zimeg zimeg added enhancement M-T: A feature request for new functionality good first issue Good for newcomers and removed auto-triage-stale labels May 30, 2024
@zimeg
Copy link
Member

zimeg commented May 30, 2024

🤔 Still thinking this'll be a good future enhancement so updating the label. Having req.query set to an empty object and populated with parsed queries seems like expected behavior to me - similar to Express.js requests with defaults to the node:querystring.parse() or URLSearchParams parsing! For reference, here are current customRoutes handlers.

Copy link

github-actions bot commented Jul 1, 2024

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

Copy link

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2024
@zimeg zimeg added auto-triage-skip Prevent this issue from being closed due to lack of activity and removed auto-triage-stale labels Jul 16, 2024
@zimeg zimeg reopened this Jul 16, 2024
@filmaj filmaj added this to the 4.x milestone Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-triage-skip Prevent this issue from being closed due to lack of activity enhancement M-T: A feature request for new functionality good first issue Good for newcomers question M-T: User needs support to use the project semver:minor
Projects
None yet
Development

No branches or pull requests

4 participants