Topic: Autocomplete error message on failed data request
ilya premium asked 3 months ago
Hi, I'm using your autocomplete component with asynchronous data loading and it works great! The only problem that bothers me is that there is no error message if the API endpoint is unavailable (for example, the API server is down or the wrong endpoint address is specified in the frontend). In this case, no error message is displayed and the loading spinner keeps spinning endlessly, which is confusing for the user. How can I make it so that in case of a failed data request a corresponding message is displayed?
Error message is shown in case of failed data request.
The loading spinner keeps spinning endlessly, no error message is shown.
You can hide the spinner by adding with JS
display: none; to
You can use
try.. catch syntax. I've prepared a snippet that shows you how:
With that, you can do whatever you want to communicate the problem. You can show a toast with information that the query didn't work, timeout to retry in a set amount of time, info below that an error occurs. In the example, I've shown you error info in the console.
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Premium
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.0.1
- Device: Laptop
- Browser: Firefox
- OS: Arch Linux
- Provided sample code: No
- Provided link: No