javascript - ReferenceError: is not defined in node.js with express -


i followed tutorial write coordinates mongodb android: http://www.learn2crack.com/2014/04/android-login-registration-nodejs-server.html

when try connect app, following error in server

referenceerror: coord not defined @ object.handle (/root/gpsavior/routes/routes.js:12:5) @ next_layer (/root/gpsavior/node_modules/express/lib/router/route.js:103:13) @ route.dispatch (/root/gpsavior/node_modules/express/lib/router/route.js:107:5) @ c (/root/gpsavior/node_modules/express/lib/router/index.js:195:24) @ function.proto.process_params (/root/gpsavior/node_modules/express/lib/router/index.js:251:12) @ next (/root/gpsavior/node_modules/express/lib/router/index.js:189:19) @ next_layer (/root/gpsavior/node_modules/express/lib/router/route.js:77:14)     @ next_layer (/root/gpsavior/node_modules/express/lib/router/route.js:81:14)     @ route.dispatch (/root/gpsavior/node_modules/express/lib/router/route.js:107:5)     @ c (/root/gpsavior/node_modules/express/lib/router/index.js:195:24) post /coord 500 1ms - 842b 

this routes.js (i put test , works)

module.exports = function(app) { app.get('/', function(req, res) { res.end("gpsavior"); }); app.get('/coord', function(req, res) { res.end("olakase"); }); app.post('/coord',function(req,res){ var num = req.body.num var lat = req.body.lat; var longi = req.body.longi; coord.coord(num,lat,longi,function (found) { <---this 1 line 12   console.log(found);   res.json(found); }); }); 

and coord.js

var mongoose = require('mongoose'); var user = require('config/models'); exports.coord = function(num,lat,longi,callback) { var num = num; var lat = lat; var longi =longi; var coord = new user({ num: num, lat: lat, longi: longi }); coord.save(); callback({'response':"ok",'res':true}); } 

it seems me missing require('coord.js'); in routes.js


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jquery - Keeping Kendo Datepicker in min/max range -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -