I'm new to yeoman's angular fullstack and seem to be structuring my server api callbacks incorrectly. I have hacked together some code. I know this is wrong but I've hit a wall - any advice would be appreciated:
for example, if I make a simple win32ole iTunes com call and return a filepath:
GET call in client/app/main.controller.js
$http.get('/api/iTunes/getxmlpath').success(function(path) {
$scope.myfilepath = path;
});
routing is set up in server/api/iTunes/index.js
router.get('/getxmlpath', controller.getxmlpath);
relevant part of server/api/iTunes/iTunes.controller.js
exports.getxmlpath = function(req, res) {
getWin32OlePath(serviceCallback);
};
function getWin32OlePath() {
try {
var win32ole = require('win32ole');
var iTunesApp = win32ole.client.Dispatch('iTunes.Application');
var xmlpath = iTunesApp.LibraryXMLPath();
console.log('got itunes xml path: '+xmlpath);
return res.json(200, xmlpath);
} catch (err) {
return handleError(res, err);
}
}
/********
error handle the callbacks
**********/
var serviceCallback =
function(response){
return function(err, obj){
if(err) {
response.send(500);
} else {
response.send(obj);
}
}
}
grunt server fails with
Error: Route.get() requires callback functions but got a [object Undefined]