I'm trying to make it so that I can look at the returned object from the first axios call, and if empty, continue to the 2nd (if it's not empty I will craft an error message)
Basically, the 2nd axios call should only happen if the userStatus object is empty. Both axios calls work independently but how Can I properly make this work so that I can hit the 2nd call if the object is empty?
Currently I get a 200 on the first axios call and an empty userStatus object in my console but the 2nd call doesn't happen
changeStatus: function(event) {
let user = this.auth_user;
axios.get('/user/' + user + '/status')
.then((response) => {
this.userStatus = response.data
})
if(this.userStatus.length < 1){
let data = {
id: event.id,
status: 'A'
};
axios.post('/status/change',data)
.then((response) => {
if (response.data.success == false) {
this.errors = [];
const errorLog = Object.entries(response.data.errors);
for (var i = errorLog.length - 1; i >= 0; i--) {
console.log(errorLog[i][1][0]);
this.errors.push(errorLog[i][1][0]);
}
}
})
}else{
console.dir('No');
}
},