PROMISES
Sun Aug 17 2025 09:13:15 GMT+0000 (Coordinated Universal Time)
Saved by
@E23CSEU1151
const apiserver = new Promise((resolve, reject) => {
const user = {
name: "tanishq dhingra",
age: 19,
};
const status = 200;
if (status === 200) {
resolve(user);
} else {
reject("some error occurred here");
}
});
apiserver
.then((result) => {
console.log(result);
})
.catch((err) => {
console.log(err); // shows actual error message
});
content_copyCOPY
Comments