Promise基础用法
const myPromise = new Promise((resolve,reject)=>{
if(condition){
resolve();
}else{
reject();
}
}) ;
makeServerRequest.then(result => {
console.log(result);
});
makeServerRequest.catch(error=> {
console.log(error);
});
Promise基础用法
const myPromise = new Promise((resolve,reject)=>{
if(condition){
resolve();
}else{
reject();
}
}) ;
makeServerRequest.then(result => {
console.log(result);
});
makeServerRequest.catch(error=> {
console.log(error);
});