I have a apex class that call an API, the data of the API like endpoint is on a custom setting, and I did a lightning component to call this API with the apex class. It works fine, only for one scenario that the QA found. When he click on the consult button and shows the data, he go to the custom setting, change the endpoint (we suffer with stability with this APIs, so it makes sense), and press the button again, and shows the spinner and a error message, finally, he go back, put the right endpoint on the custom setting and try to consult again, but then the problem shows up, the spinner just keep loading.. and nothing, I wait more than 2 minutes and nothing, and I really dont understand why have this behavior..
The function bellow, my button only call the function Ticket:
Ticket: function(cmp, event, helper){
cmp.set('v.IsSpinner', 'true');
setTimeout(() => {
this.fetchTicket(cmp, event, helper);
}, 0);
},
fetchTicket: function(cmp, event, helper){
var action = cmp.get("c.Tickets");
action.setParams({
selectedMid: cmp.get('v.midSelected')
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var TicketReturn = response.getReturnValue();
if(TicketReturn.startsWith("Erro")){
let message = "";
message = TicketReturn.substring(6);
cmp.set('v.DatatableOpen', 'false');
cmp.set('v.message', message);
cmp.set('v.messageOpen', 'true');
}
else {
cmp.set('v.messageOpen', 'false');
var Ticket = JSON.parse(TicketReturn);
}
cmp.set("v.data", listaTicket);
cmp.set('v.DatatableOpen', 'true');
}
cmp.set('v.IsSpinner', 'false');
});
$A.enqueueAction(action);
},