Restangular
Restangular is an AngularJS service that simplifies common GET, POST, DELETE, and UPDATE requests with a minimum of client code. It's a perfect fit for any WebApp that consumes data from a RESTful API.
Which makes it a perfect fit for this repository.
Restangular is a layer on top of
$http
Default Configuration
This repository provides you with a service called API
(found at angular/services/api.service.js) which configures the following:
- Content negotiation (header)
- Content type (header)
- Base URL: this means you can omit the
/api/
when calling API endpoints - error interceptor which displays the first error message in a red Toast.
- JWT support
All of these configurations are in-line with what we'd expect from the API (also inline with the dingo/api configuration).
Feel free to explore other options as documented on their repository.
Avoid using Restangular service. Use API service instead
It's recommended that you avoid using the Restangular service.
Using a service that extends Restangular (e.g.: API) would allow you to introduce other services for other APIs or other configurations.
Restangular might seem a bit hard to grasp at first. But it's totally worth it.
Once you get the hang of it, you'll be calling your endpoint in a fluent manner.
Prefer a screencast?
Updated less than a minute ago