I made a website that was done using JQuery but I am now trying to learn react but not sure how I would use axios to connect with my backend API. Does anyone know the equivalent of this to axios.
$("#log-form").submit(function (event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: '/users/login',
dataType: 'json',
data: {
'user_name': event.target.inputUsername.value,
'password': event.target.inputPassword.value
},
success: function(token){
$(location).attr('href', '/feed' ); // Redirect to logged in page
},
error: function(errMsg) {
swal(
'Oops...',
errMsg.responseJSON.body,
'error'
)
}
});
});