samedi 25 juin 2016

How do I organize my api routes vs my page routes in a SPA?

Let's say i have a resource squids

There is a page in my app to add squids with a form describing their inkiness etc, I'd say this form should be at localhost/squid

Then the post req to make a new squid goes to the same place localhost/squid

But what about when I want to GET a list of all squids? How do you/should I structure and name these similar routes?

i.e.

 // app/routes/squid.js

 router.get('/', (req, res) => res.render('squid'));

 router.post('/', (req, res) => {
     saveSquid();
     res.render('dashboard');
 });




Aucun commentaire:

Enregistrer un commentaire