Я вижу, как люди заключают метод fetch в обещание. Я не могу понять выгоду от этого? Fetch сам возвращает обещание, и вы можете извлечь из него то, что вам нужно.
let url = 'https://jsonplaceholder.typicode.com/users';
fetch(url)
.then(function(response){
//console.log(response.json());
return response.json();
})
.then(function(data){
console.log(JSON.stringify(data));
})
.catch(function(err){
//console.log(err);
err = 'this is an error';
console.log(err);
})
по сравнению с этим
return new Promise((resolve, reject) => {
fetch(url)
.then(res => res.json())
.then(data => resolve(data))
.catch(err => reject(err));
});