BigDaddy BigDaddy - 3 months ago 11
Node.js Question

ReferenceError: callack is not defined in Node.js

I am getting trouble while using callback as argument.

Here is the source.

authRequiredCall(socket1, 'media_file_add', function(userInfo, message) {
saveMediaFile(message.project_id, message.path, function(err, result) {
console.log('send media_file_add response: ' + JSON.stringify(result))
socket1.emit('media_added', result);
});
});


function saveMediaFile(project_id, file_path, callback) {
download(file_path, './uploads/')
.on('close', function () {
console.log('One file has been downloaded.');
var filename = path.basename(file_path);

putMediaToS3bucketAndSaveToDB(project_id, filename, callack);
});
}


function putMediaToS3bucketAndSaveToDB(project_id, filename, callack) {

...

uploader.on('end', function() {
var uploadedPath = s3.getPublicUrl(config.s3_config.BUCKET_NAME, newFilename, "");
console.log("FILE UPLOADED", uploadedPath);
fs.unlink("uploads/"+filename);
uploadedPath = uploadedPath.replace('s3', 's3-us-west-2');
console.log("PATH", uploadedPath);
//Saving the file in the database
addMediaFile(project_id, uploadedPath, callback);
});
}


function putMediaToS3bucketAndSaveToDB(project_id, filename, callack) {

...

uploader.on('end', function() {
var uploadedPath = s3.getPublicUrl(config.s3_config.BUCKET_NAME, newFilename, "");
console.log("FILE UPLOADED", uploadedPath);
fs.unlink("uploads/"+filename);
uploadedPath = uploadedPath.replace('s3', 's3-us-west-2');
console.log("PATH", uploadedPath);
//Saving the file in the database
addMediaFile(project_id, uploadedPath, callback);
});
}


As you can see, I am trying to send callback as an argument to SaveMediaFile, but when I invoke putMediaToS3buketAndSaveToDB function with callback argument, it returns error message.


ReferenceError: callack is not defined


I have no idea why callback is not defined while project_id and file_path has values.

Is there anyone to teach me the reason?

Help me!!!

Answer

Because you have a typo

function putMediaToS3bucketAndSaveToDB(project_id, filename, callack) 
                                                                 ^
Comments