Catching errors from service calling external API #7177
Replies: 9 comments 1 reply
-
@bobby91560, are you calling the service from the controller? If yes, then you can wrap that call within a try-catch block? |
Beta Was this translation helpful? Give feedback.
-
If you are looking for a logging component, check out #4117 |
Beta Was this translation helpful? Give feedback.
-
@dhmlau That's what I already do. With my team, we would like to catch all the errors when calling an external API, even when the API is shutdown. But it seems that the error is catch before, in the reject prodiver. Also, I want to get the request made to the external API but I don't know how to get it. All I can get it's the request from the controller method. |
Beta Was this translation helpful? Give feedback.
-
It might make sense to use interceptor to get that information. @raymondfeng, WDYT? FYI - |
Beta Was this translation helpful? Give feedback.
-
Thank for your response. I don't know why, but now I can catch the error. Maybe a wrong manipulation. Ps: Thanks for the links |
Beta Was this translation helpful? Give feedback.
-
@dhmlau I tried to use interceptor to get the request but it doesn't seem to work when using services and loopback-connector-rest. I have this service :
And this Interceptor :
What did I miss ? |
Beta Was this translation helpful? Give feedback.
-
Hi, I repeat the same question as above. Did you have some clues to achieve what I want ? |
Beta Was this translation helpful? Give feedback.
-
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
Beta Was this translation helpful? Give feedback.
-
happen to me as well, like error happend in service or controller, cannot catch this error by interceptor or middle ware |
Beta Was this translation helpful? Give feedback.
-
Hello,
How can I catch an error and the request made when calling a external API using services and loopback-connector-rest ? My purpose is to log the response's error in a different way than Loopback.
Example of what I want to do :
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions