Search code examples
javascriptmeteorflow-router

How to create a route with multiple parameters?


I am using a payment system called quickWallet and it is redirecting to the following URL on my app:

http://localhost:3000/payment-response?status=failed&id=1009891&billnumbers=1480072195&checksum=2fcdb781a18f795459b3f388135419eeae02dda12da05e2613eae8ce4f16e514

How can I handle it using FlowRouter?

This is my current route definition:

FlowRouter.route('/payment-response?',{

    name:'payment Response Received',
    action(){ 
        BlazeLayout.render('paymentResponse');

    }
});

I am getting following in my console:

kadira_flow-router.js?hash=9cd2691…:519 There is no route for the path: /payment-response?status=failed&id=1009891&billnumbers=1480072195&checksum=2fcdb781a18f795459b3f388135419eeae02dda12da05e2613eae8ce4f16e514

What am I doing wrong?


Solution

  • Define the path without using the question mark, as it is only a token that denotes the query section of the URL.

    As FlowRouter's first example shows:

    FlowRouter.route('/blog/:postId', {
        action: function(params, queryParams) {
            console.log("Yeah! We are on the post:", params.postId);
        }
    });
    

    the query parameters are available as the second argument of the action() method.

    Therefore, the code should be something like:

    FlowRouter.route('/payment-response',{
        name: 'paymentResponseReceived',
        action(_params, queryParams){
            // render your layout with the queryParams
        }
    });