Hello gus whats the difference between usingvar response = await axios.get("/api"); // OR axios .get("/api") .then(res => { response = res; }) .catch(e => { response = null; }); When using the first one when the request fails what happen with the response variable? i just need to make an if statement like that:if(response){ //do something } // OR if (response.data){ // do something } // To know if an error happened what i should do? if(response){ }else{ // there's an error here?? } Thank you guys.
Submitted February 19, 2019 at 10:01AM by ayech0x2
No comments:
Post a Comment