0
I am setting up a $http request for zip code, it happens that sometimes the API takes too long to return a reply, and the user gets stuck to proceed at checkout.
function worked, but when I tried to add the timeout it stopped.
FUNCTION:
if(this.cep && this.cep.length > 7) {
// Conneting API to get CEP Values
$http.get(`${API_URL}/carriers/correios/get-cep/${this.cep}`)
.timeout(500, () => {
.success((address) => {
this.CEPloading = false;
this.CEPerror = false;
this.validCEP = true;
updateShippingPrice(address.uf);
updatePrice();
this.bairro = address.bairro;
this.cidade = address.cidade;
this.endereco = address.end;
this.uf = address.uf;
updatePrice();
})
.error(() => {
this.CEPloading = false;
this.CEPerror = true;
});
})
}
But the function
.timeout
is to end right, obviously when he finishes reading these500
, it will stop working if there is no refresh before this execution is over.– Ivan Ferrer