Restangular, is it possible to do a Post without a previous reading?

Issue

In the documentation’s examples, each POST is preceded by a reading, is it possible to do a Post without this previous step?

Bye,
Hervé

Solution

Restangular need to know to which resource you are going to post, this is a required step, otherwise it won’t be able to generate the url.

To not get data, you just need to not use get() or getList() methods.

So any of those should work :

var account = Restangular.service("accounts");
account.post({data});

var account Restangular.oneUrl('googlers', 'http://www.google.com/1');
account.post({data});

// the 'one()' method will allow you to use 'account.save()' later which will decide to POST or PUT accordingly
var account = Restangular.one("accounts");
account.post({data});

Answered By – Salem Ouerdani

Answer Checked By – David Goodson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.