Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Node.js - Callback is not a function


I am trying to retrieve a var Hash to use it in another module. but I have a problem with Callback. I have the error "callback is not a function". I use callback because my variable hash is undefined, so i guess it's a problem of asynchronous.

Could you help me plz :)


var fs = require('fs');
var crypto = require('crypto');
var algorithm = 'sha256';

var hash = function(filename, callback){
var shasum = crypto.createHash(algorithm);
var s = fs.ReadStream(filename);

s.on('data', function(data) {
s.on('end', function() {
var hash = shasum.digest('hex')

exports.hash = hash;

app.js'/upload', upload.single('userfile'), function(req, res){

res.cookie('filename', req.file.originalname);
res.cookie('filesize', req.file.size);
var filename = __dirname +'/'+ req.file.path;

//res.cookie('hash', hash.hash(filename));

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Node.js - Callback is not a function


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription