Link to home
Start Free TrialLog in
Avatar of rbhargaw
rbhargawFlag for United States of America

asked on

Different Env API end points AngularJS

I have Angular app which gets the data from Web API. Now to get the data normally I use below code

where API_URL is the location where the Web APIs are hosted.

What is the best way to maintain API_URL for different environment?

Like for Dev, API endpoint will be server1,   for QA , API endpoint will be in Server2 and prod will be server3
Is it just enough to have config.js and hardcode the server name based on environment?



$http.post(API_URL + "/PR", JSON.stringify(data), {
            headers: {
                'Content-Type': 'application/json'
            }
        }
        ).success(function (response) {

        }
        ).error(function (error) {
        });
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rbhargaw

ASKER

If the client is in Server1 and  API is in Server2, the client atleast have to know server2 name or address to call the API. then how can we define server side variable?