Skip to content
English
  • There are no suggestions because the search field is empty.

How to hide widget with the error message "Widget could not be loaded'

This article will help you hide the error message about the widget not loading. In these cases, you can display, for example, your own scoreboard.

Problem


For some events, you can experience error message saying “widget could not be loaded”.

Solution


Although the STATSCORE offer is very extensive and we are constantly expanding our coverage, sometimes  we are unable to cover all the matches that are of interest to the client.
In such cases, we return an error that the widget could not be loaded. You can also find a more detailed description of the error in the developer tools console.

For some events, you can experience error message saying “widget could not be loaded”.

This error is usually caused by lack of mapping for a certain event. If STATSCORE is not providing such an event, and you will check console panel, there would be message: 'Mapping for provided event id does not exist'

To prevent your clients from widget with error message, you can use special code to hide widget without mapping. Here are example of code you can use to achieve that:


widget.on('error', (error) => {
   if (error.message.includes('Mapping for provided event id does not exist')) {
      element.style.display = 'none';
   } 
});

 



widget.on('error', async (error) => {
   if (error.message.includes('Mapping for provided event id does not exist')) {
      await widget.destroy();
   } 
});