How to properly use SHA-256 hashing with Node.js Crypto?

Make use of the digest() :

var crypto = require('crypto');
var hash = crypto.createHash('sha256');
var code = 'bacon';

hash.update(code);
var hashedCode = hash.digest('hex');
console.log(hashedCode);