Search code examples
node.jsparameterscallbackurl

Nodejs: I want to get values from a callback URL using get method


This is my redirect/callback URL: http://localhost:3000/users/servicespage/callback?payment_id=MOJO7717005A25534569&payment_request_id=378e45f1a7d944299a5185a9eea29c83

I want to have values of:

payment_id : MOJO7717005A25534569

payment_request_id : 378e45f1a7d944299a5185a9eea29c83

I am new to Nodejs and trying to use below approach, but it works only for 1st value when '?' sign is not there, so basically below approach is not giving any result:

router.get('/callback/:payment_id',function(req,res)
{
console.log(req.params.payment_id);
return;
}

Solution

  • What you want is query string but not URL matching.

    router.get('/callback',function(req,res)
    {
    console.log(req.query.payment_id);
    console.log(req.query.payment_request_id );
    return;
    }