Restangular doesn't work with normal API structures

I am looking into several supporting AngularJS libraries such as UI routes and other stuff. I started with Restangular today(https://github.com/mgonto/restangular).

I feel good with theory, but it adopts its own style of API URLs like the one below that return a response in square brackets ([]).

API:

https://api.mongolab.com/api/1/databases/angularjs/collections/projects?apiKey=4f847ad3e4b08a2eed5f3b54

Full demo:

Plunker demo

We may not always depend on this restangled library, as many of the APIs may not follow such a structure if there is no need to use square brackets.

Ex: FaceBook API, below is an image with API responses that don't have [] at the beginning.

Facebook API

RestangularProvider.setBaseUrl (' https://api.mongolab.com/api/1/databases/angularjs/collections ');

My question is, can Restangular be used with any API answers.

+3


source to share


1 answer


yes, regarding the doc here https://github.com/mgonto/restangular#restangular-methods

while method .all(route)

expects response as an array [{}, {}, ..]



response descriptor .one(route, id)

or get()

as an object{"what": "ever"}

0


source







All Articles