I'm setting a $ http request for zip code, so sometimes it takes too long for the API to return a response, and the user is stuck with continuing to checkout.
The 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;
});
})
}