javascript - How can I add query parameters to a node.js/express.js res.redirect function? -
i trying use redirect users google authorization page in app. situation, can't use google api modules.
i know can format res.redirect() function such: res.redirect('https://accounts.google.com/o/oauth2/auth?scope=https%3a%2f%2fwww.googleapis.com%2fauth%2fcalendar.readonly&response_type=code&redirect_uri=https%3a%2f%2flocalhost%3a3000%2fauth&client_id=690512789525-g8dbv0s1jo80u5hvevptqapeqokq7ees.apps.googleusercontent.com&hl=en&from_login=1&as=-6cc9a02870d13e22&authuser=0')
but prefer cleaner, keep query parameters in object. like:
res.redirect({uri: 'https://accounts.google.com/o/oauth2/auth, scope: 'https://............etc', response_type: 'code', etc })
each of query params attribute-value pair in object.
any ideas on how that?
a think need url.format(urlobj)
: https://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj
Comments
Post a Comment