If paypal or facebook tries to post data to your angular 2 routes, how do you access that post data? How do you see the HTTP headers submitted to your angular 2 route with a http request?
1 Answers
You won't ever see the POST data in your Angular app. Why? Because Angular is running inside of the browser when the POST requests are coming to the server. Usually your server just rewrites all (or almost all) incoming requests to your index.html and Angular by parsing the URL knows which state to show.
In other words, your POST data is received on your server but not passed through. You can catch it at the moment of rewriting and pass the data in some way (print it inside of HTML, set as cookies, etc) to your Angular app.
If I was choosing the way to pass the data I would prefer to just store the POST data in a database under some ID and then redirect the browser to the Angular app with a get parameter telling to pick the data under the specified ID.

- 23,502
- 9
- 78
- 109
-
How do I redirect the browser in this way? I tried res.status(200).json({ status: 'Login successful', success: true, token: token, user: user }) .then(res.redirect('/login'+'?=' + token)); and I get this error Error: Can't set headers after they are sent. – seanEd Feb 11 '17 at 03:33
-
I am using express and passportjs: userRouter.get('/auth/facebook/callback', function(req,res,next){ passport.authenticate('facebook', function(err, user, info), I don't know how to fetch that json token from the callback url, at the moment its just a white screen with the json coming from server side. – seanEd Feb 11 '17 at 03:57