1

I can set one api provider per angularjs app for restangular like this

    RestangularProvider.setBaseUrl('http://localhost:8080/api');

but how do i setup multiple base url's and use them selectively. I want to configure and use both of below end points

      RestangularProvider.setBaseUrl('http://localhost:8080/api');

      RestangularProvider.setBaseUrl('http://localhost:8090/apiws');

how do I do it with Restangular?

1 Answer 1

9

It's found in the docs

factory("service1", ["Restangular", function(restangular) {
  return restangular.withConfig(function(RestangularConfigurer) {

    RestangularConfigurer.setBaseUrl("http://localhost:8090/apiws");

  });

}]);


factory("service2", ["Restangular", function(restangular) {
  return restangular.withConfig(function(RestangularConfigurer) {

    RestangularConfigurer.setBaseUrl("http://localhost:8080/api");
    RestangularConfigurer.setDefaultHeaders({
      "Authorization": "Basic 123345667",
    });

  });

}]);
Sign up to request clarification or add additional context in comments.

1 Comment

how to declare those URL's in route.js

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.