Last active
July 13, 2019 15:53
-
-
Save ohoroyoi/4c50cc141f7f68ac2526303bc5b18a9a to your computer and use it in GitHub Desktop.
출력결과가 어떻게 될까요
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const todosPromise = new Promise((resolve, reject) => { | |
// const condition = Math.random() > 0.5; //true or false | |
// return condition ? resolve('성공했어요') : reject('실패했어용'); | |
// }); | |
// // console.log(todosPromise); | |
// todosPromise.then((data) => { | |
// console.log(data); | |
// }).catch((err)=>{ | |
// console.log(err); | |
// }); | |
const getTodos = (id) => { | |
return new Promise((resolve, reject) => { | |
$.getJSON(`https://jsonplaceholder.typicode.com/todos/${id}`, (data) => { | |
resolve(data); | |
}); | |
}); | |
} | |
console.log("하나"); | |
getTodos('1') | |
.then((data) => { | |
console.log(data); | |
console.log("둘"); | |
return getTodos('2'); | |
}).then((data2) => { | |
console.log(data2); | |
return getTodos('3'); | |
}).then((data3)=>{ | |
console.log(data3); | |
return getTodos('4'); | |
}).then((data4) => { | |
console.log(data4); | |
}).catch((err) => {console.log(err)}); | |
console.log("셋"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment