const promiseFour = new Promise(function(resolve, reject){ setTimeout(function(){ let error = true if (!error) { resolve({username: "hitesh", password: "123"}) } else { reject('ERROR: Something went wrong') } }, 1000) }) promiseFour .then((user) => { console.log(user); return user.username }).then((username) => { console.log(username); }).catch(function(error){ console.log(error); }).finally(() => console.log("The promise is either resolved or rejected")) https://github.com/hiteshchoudhary/js-hindi-youtube/blob/main/09_advance_one/promises.js