cphill cphill - 1 year ago 216
Javascript Question

JavaScript Invoking String

I am running into a string violation error with my ORM that is related to the value being passed to the authenticationToken property in my method. Is this due to the fact that I'm returning the method? The value I am looking to pass is


.post(function(req, res, organization){

function token() {
return crypto.randomBytes(20, function(err, buf){

organizationId: req.body.organizationId,
memberEmail: req.body.addMember,

return models.User.create({
email: req.body.addMember,
authenticationToken: token()

Here is my error:

Unhandled rejection SequelizeValidationError: string violation: authenticationToken cannot be an array or an object

Answer Source

Could be a missing return keyword? The anonymous function in your call to crypto.randomBytes doesn't return anything.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download