ERR_EMPTY_RESPONSE (no data received)
I thought this might be somethign to do with the middleware settings, but I have the default middleware.js file (see below). Please help
I use the following bootstrap script to create Category objects in my local MongoDB.
var categories = [
{"title" : "Technology Matters", "description": "Blogs on latest technologies"},
{"title" : "Innovative Ideas", "description": "Innovative ideas on the next project"},
{"title" : "Comments on Hot Topics", "description": "My comments on the hot topics"}
];
module.exports = function(server) {
var dataSource = server.dataSources.homeMongoDB;
dataSource.automigrate('Category', function(err) {
if (err) throw err;
var Model = server.models.Category;
//create some sample data
var count = categories.length;
categories.forEach(function(category) {
Model.create(category, function(er, result) {
if (er) return;
console.log('Category created: ', result);
count--;
if (count == 0) {
console.log('Categories all created!');
dataSource.disconnect();
}
});
//could define a model scope here
});
});
};
my middlware.js file:
{
"initial:before": {
},
"initial": {
},
"session": {
},
"auth": {
},
"parse": {
},
"routes": {
},
"files": {
"loopback#static": {
"params": "$!../client"
}
},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"errorhandler": {}
}
}
and my server.js file:
var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback();
app.start = function() {
// start the web server
return app.listen(function() {
app.emit('started');
console.log('Web server listening at: %s', app.get('url'));
});
};
app.use('/express-status', function(req, res, next) {
res.json({ running: true });
});
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});