Question Protected by gnat
2 edited title
| link

Is it a bad choice to consume the REST API also from the back-end too?

    Tweeted twitter.com/#!/StackProgrammer/status/531183715804651520
1
source | link

Is a bad choice to consume the REST API also from the back-end?

Using a REST API for front-end code is a desiderable and quite common practice.
However, I was wondering if using it also for the back-end could be a good choice.

What I mean is leaving the burden of retrieving data from the database all to the API, and then call it from other parts of my back-end (mainly views and controllers) whenever I need to query the database, instead of doing it directly.

One thing I'm really concerned about is sharing some code between front-end and back-end, and using the API as a common source of data would be very handy.

So the question is, are there some reasons which make this a bad idea?