javascript - mean stack route not returning a response -
i trying create controller /projects returns of info in collection 'work'. info there , phone call completes 200 returns [], or test:test if uncommented. can point me in right direction, i'm new mean stack.
server/controllers/work.js
'use strict'; /** * module dependencies. */ var mongoose = require('mongoose'), work = mongoose.model('work'); exports.all = function(req, res) { work .find() .exec(function(err, project) { console.log(project); res.json(project); //res.json({"test":"test"}); }); }; public/system/controllers/work.js
'use strict'; angular.module('mean.system').controller('workcontroller', ['$scope', 'global', '$http', function ($scope, global, $http) { $scope.global = global; $http.get('/projects').success(function(d) { }).error(function(d) { }); }]); server/routes/work.js
'use strict'; // user routes utilize users controller var work = require('../controllers/work'); module.exports = function(app) { app.get('/projects', work.all); };
found issue, reason collection beingness named 'works' instead of 'work' somewhere. maybe done automatically in mongoose or fixed issue.
javascript node.js mongodb mean-stack
No comments:
Post a Comment