npm - How to redirect PUT request to POST request in express router route handler? -


i handling put /api/checkout route express router: this.router.put('/:id/checkout', (req, response, next) => { /*...*/ });

now handling different types of payments different third party services 1 of expects post request looking way handle put request executing post request third party service endpoint. how do ?

what did @ point execute post request directly request.post.

the challenge @ point how handle resource moved response.

request.post({   url  : 'https://paymentgateway.com/charge',   form : {     product_id        : product_id,     amount            : amount   } }, (err, httpresponse, body) => { 

the response here httpresponse.statuccode === 302 , body === <html><head><title>object moved</title></head><body>. not sure how handle this. html form same request parameters automatically redirects client redirect url.

returning httpresponse client requesting checkout action job. client handles redirection automatically.

}, (err, httpresponse, body) => {    if (err) {     logger.error(err);     return response.status(err.code || 500).send(err);   }    return response.status(httpresponse.statuscode).send(httpresponse); }); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -