i'm trying to understand the difference between ajax and axios. i'm experimenting with two request methods for user login in react development using ajax and axios -- with all else being equal. when reloading the page after successful login using ajax, the user remains logged on, but when using axios, the user is no longer logged in after page refresh. is this difference expected?
loginPageAjax.js
componentDidMount() {
$.ajax({
method: 'GET',
url: '/retrieveUser',
success: (res) => {
if (res.id) this.loginCheck(res);
}
});
}
loginPageAxios.js
componentDidMount() {
axios({
method: 'GET',
url: '/retrieveUser'
})
.then(res => {
if (res.id) this.loginCheck(res);
})
}