I am learning Node js and I get following error when run the code.
TypeError: callback is not a function
Any help will be appreciated.
Following is my code
console.log('before');
getUser(1, getRepositories);
console.log('After');
function getRepositories(user) {
getRepositories(user.gitHubUsername, getCommits);
}
function getCommits(repos) {
getCommits(repos, displayCommits);
}
function displayCommits(commits) {
console.log(commits);
}
function getUser(id, callback) {
setTimeout(() => {
console.log('Reading a user data from database...');
callback({ id: id, gitHubUsername: 'Gary' });
}, 2000);
}
function getRepositories(username, callback) {
setTimeout(() => {
console.log('Calling Github API....');
callback(['repo1', 'repo2', 'repo3']);
}, 2000);
}