---
agentTools:
  projectIndex: https://laravel-angular.readme.io/llms.txt
---

# Restangular

> [Restangular](https://github.com/mgonto/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.

[block:callout]
{
  "type": "info",
  "title": "",
  "body": "Restangular is a layer on top of `$http`"
}
[/block]

# 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](https://github.com/mgonto/restangular).

[block:callout]
{
  "type": "success",
  "title": "Avoid using Restangular service. Use API service instead",
  "body": "It's recommended that you avoid using the Restangular service.\nUsing a service that extends Restangular (e.g.: API) would allow you to introduce other services for other APIs or other configurations."
}
[/block]

[block:callout]
{
  "type": "warning",
  "title": "",
  "body": "Restangular might seem a bit hard to grasp at first. But it's totally worth it.\nOnce you get the hang of it, you'll be calling your endpoint in a fluent manner."
}
[/block]

> Prefer a screencast?

[block:html]
{
  "html": "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/RHQNpw-XmpI\" frameborder=\"0\" allowfullscreen></iframe>"
}
[/block]