Search code examples
restrestangular

Change restangular url so that it doesn't go to a concatenation of localurl+serverurl?


When I try to run the command:

return Restangular.one('me').get();

I get the following response

GET http://localhost:8100/serverurl:8666/api/v1/me 404 (Not Found)

How do I change so that all requests use the url below instead, and where in my code should I make this change?

http://serverurl:8666/

Solution

  • You should set your base url

    app.config(function(RestangularProvider) {
      RestangularProvider.setBaseUrl('http://serverurl:8666/api/v1');
    });
    

    then everywhere inside app you can use

    Restangular.one('me').get();
    

    It will build GET request to http://serverurl:8666/api/v1/me