0

I'm trying to make a post but below does not appear to work it does not post but console.log() looks like a put request i.e

http://127.0.0.1/api/v1/participant?account=%7B%22pk%22:1%7D&[email protected]

factory

app.factory('CbgenRestangular', function(Restangular) {
    return Restangular.withConfig(function(RestangularConfigurer) {
        RestangularConfigurer.setBaseUrl('http://127.0.0.1');
    });
});

controller

$scope.participant = {email :$scope.email, password: "", account:{pk:1}};
CbgenRestangular.all('api/v1/participant').post("participant", $scope.participant);

What I'm I doing wrong?

1 Answer 1

2

according to the documentation (https://github.com/mgonto/restangular#lets-code):

// First way of creating a Restangular object. Just saying the base URL 
var baseAccounts = Restangular.all('accounts');

var newAccount = {name: "Gonto's account"};

// POST /accounts 
baseAccounts.post(newAccount);

note that post has a single input

you can add 'api/v1' to your base address - there's no need to carry it around (https://github.com/mgonto/restangular#setbaseurl)

I would also suggest using the plural form for a resource route, but that's a convention that some people don't follow - I guess it is a matter of taste

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.