When using VueUse axios for example, you get a centralized approach to handle errors (the error property returned by the composable. This means that the composable handles the error returning to you the result that you can display to a user in a friendly way. And you don't need to write try/catch in every place to achieve that as it is handled by the composable.
If not using utility like the one above, you could create your own useApiClient composable that could be a wrapper around the fetch method that will also by default handle errors and populate a property to show you what the error code and message was.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
When using VueUse axios for example, you get a centralized approach to handle errors (the
error
property returned by the composable. This means that the composable handles the error returning to you the result that you can display to a user in a friendly way. And you don't need to writetry/catch
in every place to achieve that as it is handled by the composable.If not using utility like the one above, you could create your own
useApiClient
composable that could be a wrapper around thefetch
method that will also by default handle errors and populate a property to show you what the error code and message was.