How to set multiple baseURL using restangular in angularjs

408 Views Asked by At

below code is my app.js file, and my problem is i have declared multiple port number(base URL) its working fine.

 app.config(function (RestangularProvider) {
    RestangularProvider.setBaseUrl('http://localhost:8086/mmg/api/v1/');
    RestangularProvider.setDefaultHeaders({
        "X-API-KEY": "MMGATPL",
        "Content-Type": "application/json",
      });

});


app.factory('FirstRestangular',[ 'Restangular',function (Restangular) {
    return Restangular.withConfig(function(RestangularConfigurer) {
    RestangularConfigurer.setBaseUrl('http://localhost:8085/mmg/api/v1/');
    RestangularConfigurer.setDefaultHeaders({
        "X-API-KEY": "*******",
        "Content-Type": "application/json",
         });

});
}]);

How should i declare base URL in route.js

    app.config(function (RestangularProvider, $stateProvider, $urlRouterProvider) {
     RestangularProvider.setBaseUrl('http://localhost:8086/mmg/api/v1/');
};

I can set only one base URL, if i declared multiple URL its not fetching from database.

How to resolve this? I have tried using random declaration but it didt work Thanking in advance for the answer.

0

There are 0 best solutions below