0

I'm developing Angular app where user opens a URL (https://localhost:4200/bookingDone) fills the forms.

After that user clicks on PAY button and a POST request is fired to server to payment gate way with this

postBackURL: 'https://localhost:4200/oilChanger' 

After creation of token on server. Server fires a GET call back to my angular app using url provided in postBackURL. How can I handle is call and route the UI to the oilChanger. I get this error in console:

GET https://localhost:4200/oilChanger?auth_token=1876038377738301950287234324&postBackURL=https%3A%2F%2Flocalhost%3A4200%2FoilChanger 0 ()

core.js:1350 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …}

Now problem is that my corresponding Angular Page that I configured for that Callback URL is not opening. I configured /oilChanger page in RouteProvider, but that seems not to be working.

However, if I open the url directly via browser, it gets opened. my http call:

this.http.post('https://abcd.com/Index.jsf', body.toString(), options).subscribe(response => { console.log(response) }); 

How this scenario can be handled? Any help would be greatly appreciated.

3
  • 2
    "I configured /oilChanger page in RouteProvider, but that seems not to be working." Then, why don't you show your RouteProvider or some more code? This is quite light to help you here! Commented Jul 10, 2018 at 8:34
  • Please show more html and js code. Commented Jul 10, 2018 at 8:35
  • Are you sure you need post request to 'https://abcd.com/Index.jsf'? Commented Jul 10, 2018 at 8:36

1 Answer 1

3

How to receive GET request in an AngularJS page?

You can't.

Angular is a client-side JavaScript framework.

HTTP requests are received by servers, not clients.


  1. You need to run an HTTP server (you need one to deliver the Angular app to clients anyway).
  2. You need to use a postBackURL that the service you are using can use to access that server. localhost means "This computer" and the service making the postback request will have a different idea about what "this computer" is to your web browser.
  3. You need to handle the postback request on your HTTP server. How you do that will depend on what you want to do with the information in the request. If you need to get it back to Angular, then you'll probably want to also set up a WebSocket connection between your Angular app and your HTTP server.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.