import axios from 'axios';
export const onAuthenticate = payload => {
const URL = `YOUR_URL`;
return axios(URL, {
method: 'POST/GET',
headers: {
'content-type': 'application/json', // whatever you want
},
data: payload,
})
.then(response => response.data)
.catch(error => {
throw error;
});
};
in you App.js
import * as AuthenticateAPI from 'api/AuthenticationAPI';
// in your CDM
componentDidMount(){
AuthenticateAPI.onAuthenticate(payload).then((res)=>{ //any payload you want to send just for example
you can get response here in then block
})
}