angular - No se muestra el mensaje de error en modo "offline"
Estoy trabajando en la aplicación que tiene un método patch para enviar datos a la base de datos. Estoy usando un método toPromise() para obtener la respuesta y hacer lo que sea necesario según la respuesta, sin embargo, si apago la conexión de red y envío mi formulario, todavía recibo el "Mensaje OK" aunque claramente hubo un 'error' porque no hay conexión.
¿Qué estoy haciendo mal?
PD: Si formSendStatus es falso, debe mostrar el mensaje de error.
Aquí está mi servicio:
return this.http.patch(url, JSON.stringify(data),
{ headers: this.httpOptions.headers,
responseType: 'text'
}
);
Y mi componente
return this.hs.edit(data).toPromise().then(
() => {
this.showDialog = true;
this.hs.formSendStatus.next(true);
setTimeout( () => {
this.router.navigate(['information']);
}, 2000 );
},
(e) => {
this.showDialog = true;
this.hs.formSendStatus.next(false);
setTimeout( () => {
this.showDialog = false;
}, 2000 );
}
).catch(
(e) => {
this.showDialog = true;
this.hs.formSendStatus.next(false);
setTimeout( () => {
this.showDialog = false;
}, 2000 );
}
);