Promise then(...) always return 'undefined'

From Node Lecture Asynchronous JavaScript : 8- Consuming Promises
Hello Forum,

I’m confused why the third then( ) always return undefined.

getUser(1)
 .then(user => getRepositories(user.gitHubUsername))
 .then(repository => getCommits(repository[0]))
 .then(com => console.log('Commit', com)) // this always return 'undefined'
 .catch(error => console.log('Error', error.message ));

Thanks,
Fmarsella

Following are the rest of my codes:

hi,

have a look at your getCommits function; you’ve forgotten to add “return” before " new Promise…"

1 Like