Vinodkumar Subbaiah
Vinodkumar Subbaiah

Reputation: 11

How to redirect to external URL with post parameters?

When user hits my end point it has to be redirected to an external URL with url encoded form parameters.

End point

https://example.com

Form parameters

name:testing, id: 123456

This is what I tried for now in Express. It gets redirected to the URL but I don't know how to add parameters.

app.get('/', (req, res) => res.redirect(302,'https://example.com')) 

Upvotes: 0

Views: 1448

Answers (1)

Cod3n0d3
Cod3n0d3

Reputation: 253

You can't redirect with parameters as a POT request.

You have 2 options:

  1. add parameters to query string:

    Example: https://example.com/?ParameterOne='xxx'

  2. use res.render, with parameters and use the following through the view engine u use.

    Example: res.render('index', {parameterOne: xxx})

Upvotes: 1

Related Questions