Skip to content

Commit 108f485

Browse files
Resolved using callback function
1 parent ff468a6 commit 108f485

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

promises/app.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ function getPosts(){
4040
},1000);
4141
}
4242

43-
function createPost(post){
43+
function createPost(post,callback){
4444
setTimeout(()=>{
4545
posts.push(post)
46+
callback();
4647
},2000)
4748
}
48-
getPosts();
49-
createPost({title:"Post three",body:"This is post three"})
49+
50+
createPost({title:"Post three",body:"This is post three"},getPosts)

0 commit comments

Comments
 (0)