If the site redirects to my target site with a form post, I want to be able to read the incoming data from the post request using angular 2 typescript. Is there a way to do it?
Asked
Active
Viewed 2,889 times
1
-
you need to pass the data from one components to another is it so ?.. – balajivaishnav Feb 09 '17 at 07:21
-
no. My post data is coming from external site. I want to capture it at my end. – namrata Feb 09 '17 at 07:22
-
external site means API ?.. – balajivaishnav Feb 09 '17 at 07:23
-
He means a website posts to his website simply put. as my answer states, this requires server handling if you want something like this. – Mathijs Segers Feb 09 '17 at 07:24
-
2create a model class and declare corresponding variables, get the data from an external site via services and assign the data to the model's variables, inject the model as a provider in app.module, now you can import that model and access the variables with the external site values, thats it – balajivaishnav Feb 09 '17 at 07:34
-
Is there a way to extract it in Owin in - ConfigureAuth(IAppBuilder app) ? – namrata Feb 09 '17 at 07:36
-
Not an expert here, but any C# handler should be able to access the values, how to share with angular no experience with that. – Mathijs Segers Feb 09 '17 at 07:55
1 Answers
0
Basically it's not possible with just angular. Simply put this answer: How to read the post request parameters using javascript
However, depending on your server you have options; When parsing the request you could use a server side language to generate your index.html. e.g. a PHP file.
At this point you could print the post data into a script tag e.g. with PHP
<script type="text/javascript">
var somePostData = <?php echo $_POST['some_data']; ?>
</script>
Could that be something for you to work with? Of course you'd have to properly escape the data. then it would be accessible like:
window["somePostData"] in your angular code, or you define the type.

Community
- 1
- 1

Mathijs Segers
- 6,168
- 9
- 51
- 75