- axios => server call npm install axios
- react-toastify => for message displaying npm install react-toastify
server url => BASE_URL = http://localhost:9090 BASE_URL/api/v1/auth/register
how to access error message:
errorObject.response.data.password
usestate
error.errors.response.data.name
login url => BASE_URL = http://localhost:9090 BASE_URL/api/v1/auth/login
{
username:"",
password:""
}
In return get a token and store it in localhost.
POST
- Create Context
context = createContext(null) Provider- provides Consumer- consumes
-
Wrap our components in Provider <context.Provider value = {user}> children </context.Provider>
-
consume the value with the help of consumer <context.Consumer> { (user)=>(
{user.name}) } </context.Consumer>