Questions tagged [restangular]

Restangular is an AngularJS service to handle Rest API Restful Resources properly and easily

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.

Restangular is available on GitHub and is released under the MIT open-source licence.

925 questions
134
votes
5 answers

What is the advantage of using Restangular over ngResource?

ngResource already seems really simple to implement things with... What are the Advantages / Disadvantages of using Restangular over ngResource? 1.1.3 $resource will return promises and can be implimented using latest PR commit. Will future support…
Dan Kanze
  • 18,485
  • 28
  • 81
  • 134
57
votes
2 answers

Why do I receive error ... unexpected request: GET /internalapi/quotes

I've defined the following service in my angular app : services.factory('MyService', ['Restangular', function (Restangular) { return { events : { loading : true }, retrieveQuotes : function() { return…
Simon Lomax
  • 8,714
  • 8
  • 42
  • 75
34
votes
3 answers

What is the difference between .all() and .one() in Restangular?

What is the difference between these two? Both seems to make a GET to /users and retrieve them. Restangular.one('users').getList().then(function(users) { // do something with users }); Restangular.all('users').getList().then(function(users) { …
user2906759
  • 821
  • 1
  • 9
  • 15
30
votes
0 answers

Comparison of Restangular vs. JSData (formerly Angular-data)

One of the things about Angular that's both a feature and a point of complexity, is that it's not very opinionated about how to interact with a RESTful API. I know about $resource, Restangular, and various ideas you can find on rolling your own. In…
jmq
  • 2,359
  • 18
  • 32
29
votes
5 answers

Immediately return a resolved promise using AngularJS

I'm trying to get my head around promises in JavaScript (in particular AngularJS). I have a function in a service, let's call it fooService, that checks if we've loaded some data. If it has, I just want it to return, and if we haven't, we need to…
samturner
  • 2,213
  • 5
  • 25
  • 31
27
votes
4 answers

How to send an array of parameter through GET with Restangular

I have to send an array of filters through get parameters in an API like this : /myList?filters[nickname]=test&filters[status]=foo Now if I send an object directly like this : Restangular.one('myList').get({filters: { nickname: 'test', …
Jihel
  • 796
  • 1
  • 5
  • 13
22
votes
1 answer

Return Ok with empty list VS. No content

I wrote a web API that returns 204 (No Content) when a client requests all elements on a collection but the collection is empty. For example: /api/products returns 204 when there are no products. Now my problem is that I'm trying to consume the API…
Snæbjørn
  • 10,322
  • 14
  • 65
  • 124
21
votes
5 answers

MongoDB: how to find 10 random document in a collection of 100?

Is MongoDB capable of funding number of random documents without making multiple queries? e.g. I implemented on the JS side after loading all the document in the collection, which is wasteful - hence just wanted to check if this can be done better…
Iladarsda
  • 10,640
  • 39
  • 106
  • 170
21
votes
3 answers

Restangular: getList with object containing embedded array

In my AngularJS project I'm trying to use the Restangular getList method but it's returning an error because the API response is not directly an array but an object containing an array. { "body": [ // array elements here ], "paging":…
Guilhem Soulas
  • 1,975
  • 2
  • 18
  • 30
20
votes
5 answers

Django REST framework post array of objects

I am using Django REST framework for API and Angular SPA with Restangular to communicate with the API. Sometimes, I have to add more than one object using the API and I think I can send them together in an array and do this in one request. I receive…
valkirilov
  • 1,823
  • 3
  • 20
  • 26
20
votes
1 answer

Error: Failed to instantiate module restangular due to: '_' is undefined

When first using Restangular on a working website I got the following JavaScript error: Failed to instantiate module restangular due to: '_' is undefined What am I missing? What does it mean that '_' is undefined (in the Restangular module)?
Omar
  • 1,493
  • 12
  • 14
19
votes
1 answer

Restangular get clean response object from POST request

I'm trying to use Restangular service, but I have gotten one problem which I can't solve. For example I'm doing the POST request and I want to get clean response Object, but in my response Object wrapped all Restangular methods, I know may be it's…
Narek Mamikonyan
  • 4,601
  • 2
  • 24
  • 30
19
votes
1 answer

Restangular POST form data in json format in Angular JS

I am new to Angular JS and I am in a need to use restangular POST of form data in json format. Also I am new to the POST functionalities, can anyone tell me how I can do it?? MY Index Page:
Kiran Kumar
  • 1,610
  • 3
  • 16
  • 22
16
votes
4 answers

Uncaught ReferenceError: _ is not defined from restangular

I'm getting this error: Uncaught ReferenceError: _ is not defined from restangular when trying to use Restangular. HTML