Promise Curly Bracket

return getUser(1)
.then(user => { getRepositories(user)} )
.then(repo => { getCommits(repo) } )
.then(commit => {console.log(“COMMIT” , commit)})
.catch(error => console.log(error) ) ;

After placing the curly bracket , the promise doesn’ t wait for the result before execute the next promise .

Your code blocks in curly braces don’t return anything. So the thens will all immediately return a resolved promise. Either remove the curly braces or let your code blocks return a promise.

Thanks. Problem solved but still don’t get the idea between placing a brackets will affect not returning the Promise ?

When you use curly braces you declare a code block. Code blocks don’t have a value unless you explicitly return one. Think of a code block


Which of of the two promises should be the value the code block evaluates to?