I've been testing my JS code on different browsers but it doesn't seem to work on some of them and on mobile either.
JS
function req1() {
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then(response => response.json())
.then(json => {
var title = json.title;
var body = json.body;
document.getElementById("newsTitle").innerHTML = title;
document.getElementById("newsContent").innerHTML = body;
document.getElementById("newsContent2").innerHTML = body;
});
}
req1();
By reading this question I understood that the problem could be related to '=>' because it is a ES6 element and not all the browsers support it. But as you can see here it seems to be the way to get those json data: https://jsonplaceholder.typicode.com/
Is there a way to avoid using '=>' in this function to make it work on all the browsers?
Here the error that I get on Safari 9 for example:
I tried some solutions but now I get this error:
posts are not printed yet, any idea?