Hi Tito,
If what you want to do is to organize your routes in several files, say one 
per URI you could try something like this:

In your files virtuamachines.js and  hardware.js
var express = require('express');
var router = express.Router();

var routes = {
 get: function(req, res, next) {
                (....)
 }
 //... post, put, delete, etc.
}

router.get('/:name/', routes.get);
router.post('/', routes.post);
...
module.exports = {routes: routes, router: router};


And then in index.js


var express = require('express');
var virtualmachines = require('./routes/virtualmachines').router;
var hardwares = require('./routes/hardwares').router;

app.use('/virtualmachines/', virtualmachines);
app.use('/hardwares/', hardwares);


Regards,
Arnaud.




Le mercredi 14 février 2018 20:55:33 UTC+1, Tito a écrit :
>
> Greetings,
>
> I want to use one index file that is called from my main app.js
>
> routes = require('./routes')(app);
>
> The index.js in that routes folder calls
>
> module.exports = function(app) {
> require('./virtualmachines')(app); 
> require('./hardwares')(app); 
> };
>
> but only api calls from virtualmachines are coming with results when I do
>
> curl localhost:8080/api/virtualmachines
>
> What am I missing here. Why only the first route loads?
>
> Thanks much!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to