Here is the code snippet I'm working with:
<script>
export default{
props:['idStore'],
methods:{
addFavoriteStore(event){
$(function () {
$(document).ajaxError(function (e, xhr, settings) {
if (xhr.status == 401) {
window.Laravel.baseUrl+'/login'
}
else {
event.target.disabled = true
const payload= {id_store: this.idStore}
this.$store.dispatch('addFavoriteStore', payload)
setTimeout(function () {
location.reload(true)
}, 1500)
}
});
});
}
}
}
</script>
When the favorite button is clicked, it triggers the addFavoriteStore method.
After running the addFavoriteStore method, a condition is supposed to check if the user is unauthorized. However, despite trying this conditional statement, it does not seem to work as expected. No errors are showing up in the console either.
Why might the condition be failing to work properly?