запись () => эквивалентно function()
почему фетч самовызывался
fetch('info.json', {method : 'GET'})
.then(function(response) {
return response.json();
})
.catch(alert); // вернет промис
fetch('info.json', {method : 'GET'})
.then(function(response) {
return response.json();
})
.then(function(json) {
console.log(json);
})
.catch(alert); // выполнит действие над промисом и соответственно результатом запроса
JSON.parse(
JSON.stringify({
"data0": "<h1>hello</h1>",
"data1":"<h1>world</h1>",
"data2":"<h1>hello wordls</h1>"
})
)