Is this code a Promise ?
let fetchData = fetch("https://jsonplaceholder.typicode.com/users")
.then(res => res.json())
.then(data => {
console.log(data[0].name)
})
.catch(err => {
console.log('Opps! something went wrong :(')
})
What is the difference between having a Promise like this and create a new Promise which has resolve and reject to invoke .then and .catch blocks ?
fetch function is returning a Promise object that's why you are able to use .then and .catch blocks.