veekram
veekram

Reputation: 85

Handle post request in reactjs

I have have trying to communicate to third party application from react app. Whenever user tries to browse say : http://somesite.com/ , user is redirected to http://authenticationsite.com/ . This application then responds back with POST data in first site if the user is successfully authenticated. I have routes for handling get request. How can I possibly handle POST request from third party apps which contains information like token in the react app?

Upvotes: 1

Views: 868

Answers (1)

idjuradj
idjuradj

Reputation: 1465

You basically want to implement sort of token based authentication?

When you load your app (or a component within your app), make a POST request to the authorization website using some ajax library, like axios, fetch or jquery ajax. Depending on the response from the 3rd party server, save the token somewhere (localStorage for example) and proceed with the rest of the flow.

Hope this helps! If you have any questions, or I misunderstood your question, please let me know, and we will proceed from there.

Upvotes: 2

Related Questions