Can a promise be created without using the constructor new promise() or =>resolve & =>rejected? Let's explore an alternative method below.
export function getItById(id) {
return fetch(`path`, {
method: 'GET',
}).then(rslt => {
if (!rslt || !rslt.ok) {
throw new Error('failure !');
} else {
return rslt.json();
}
});
}