I want to check if the request is timeout when I send a request to the port. I just want to print an error when the request is timeout.
myService.service.ts
checkStatus() : Observable<any> {
return this.http.get<any>('http://127.0.0.1:3001'); // simple example
}
myComponent.ts
this.myService.checkStatus.subscribe(() => {},
(err) => {
// if the timeout error is print error
}
}
I just want the error to be removed from the screen when the timeout error is fixed. if error 404 or a different error returns, I do not want the operation to be performed and printed to screen.
in short, it is as follows
- A request will be sent to the port and checked for a timeout error.
- If there is a timeout error, an error will be printed on the screen.(404 or different errors will not print, only timeout error)
- if there is a timeout error, it will be checked if the error persists, and if the error does not occur, the text on the screen will be removed.