0

I have created a login form where i accept the user email and password.

I want to make api call to api server to validate the credentials against database how can i make a ajax request . I have heard of Redux can that be used for making ajax request.

class LoginComponent extends React.Component{

 constructor(){
  super()
 }

 handleEmailChange(e){
  //... email validation stuff
 }

 handlePasswordChange(e){
  //...
 }

 handleSubmit(e){
  //..login logic goes here
 }

}
kailash yogeshwar
  • 836
  • 1
  • 9
  • 26

1 Answers1

2

You're going to need to configure the redux-thunk middleware to support asynchronous actions. Then, you'll want to pick an asynchronous library to handle actual http requests. isomorphic-fetch and axios are popular ones.

The redux documentation has a great async action example of how to get started with your exact request

You'll also find some very helpful information in another related post by Dan Abramov, the creator of redux.

Community
  • 1
  • 1
John F.
  • 4,780
  • 5
  • 28
  • 40