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

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(); } });