Receiving POST from external application in AngularJS

6.7k Views Asked by At

I'm writing an application which uses AngularJS 1.4.0 which requires the ability to receive POST data from an external application. I know that routes in AngularJS often do parameters in the URL such as this:

.when('/section/:param', {
    templateUrl: 'views/home.html',
    controller: 'AppCtrl'
})

The problem with this style is that in my case the parameter is often very very long and it will cause the web server to ignore / truncate the request / parameter because the URL exceeds the maximum URL length.

For this reason, instead of a standard GET style parameter, I would like the application to receive a POST parameter, but I am not sure how to capture the parameter(s) and value(s).

Is there a way for Angular to capture the POST parameters directly? My second option would be to simply have an ng-init which uses a backend to grab the values, but I'd prefer to keep the parameters solely in Angular if possible. Thanks!

1

There are 1 best solutions below

4
On BEST ANSWER

Except if your willing to do some weird black magic by setting cookies server-side - or something similar - there is no way to this in javascript.

POST values are sent to the server upon request, it's impossible capture these with javascript running in your browser.

Check out this answer aswell: How to read the post request parameters using javascript