1

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?

namrata
  • 2,235
  • 5
  • 28
  • 35

1 Answers1

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