Tuesday, 2 May 2017

typeerror undefined is not a function in node js

I have a simple form which gives me below error. TypeError: undefined is not a function on line no 20. plese help me

var path = require('path')
var funcs = require('./funcs')
var encodeName = funcs.encodName

var session = {
  username: process.argv[2],
  lastMessageHash: process.argv[3]
}

if (!session.username || !session.lastMessageHash) {
  console.log('Usage: node index.js <username> <hash>')
  process.exit(0)
}

// 1. load the database
var dbFile = path.join(__dirname, 'db', 'index.json')
funcs.loadDb(dbFile, function (err, db) {

  // 2. encode the name
  var encoded = encodeName(session.usrename) // error line no 20

  // 3. find the user's inbox
  var inbox = funcs.findInbox(db, encoded)

  // 4. find the next message
  var nextMessage = funcs.findNextMessage(inbox, session.lastMessageHash)

  // 5. print out the message.
  // Paste the console output into the "Solution" field and you're done!
  console.log(nextMessage)
})

I am working on simple page with database conncection on my node js project. i am newbe in nodejs.



via patel

No comments:

Post a Comment