function doSomething() {
return new Promise((resolve, reject) => {
resolve("WWW");
});
}
function doSomething2() {
return new Promise((resolve, reject) => {
reject("XXX");
});
}
doSomething().then((data) => {
console.log(data); // WWW
}).catch((data) => {
console.log(data);
});
doSomething2().then((data) => {
console.log(data);
}).catch((data) => {
console.log(data); // XXX
});
目次