Javascript stop working with fetch(URL)

Hi! Im using an embebed html in a layout. The idea is to change an image depending on the value of an API call.

When I put “fetch(URL);” inside the javascript, the display show nothing.

For example, only for testing purpuse, this code works:

<script>
function changeImage() {
	const URL = "url";
	tst = "https://dam.ngenespanol.com/wp-content/uploads/2019/03/luna-colores-nuevo.png" ;
    document.getElementById("changer").src = tst;
}
</script>

but this one no:

<script>
function changeImage() {
	const URL = "url";
	fetch(URL);
	tst = "https://dam.ngenespanol.com/wp-content/uploads/2019/03/luna-colores-nuevo.png" ;
    document.getElementById("changer").src = tst;
}
</script>

And in the HTML:

<body onload=changeImage();>
	<img  src="" id="changer">
</body>

CMS Version: 2.3.2
Player Type: Windows player - v2 R201

Thanks!

Hi and welcome!

The fetch API isn’t available in IE11 which is used by Windows R201. You could either upgrade your player to R252 which uses Chrome, or you could swap out fetch for jQuery $.ajax()

Thanks,
Dan

Thanks! worked with R252.

1 Like
The Xibo Community site uses cookies. What are cookies?