Solved

Different Env API end points AngularJS

Posted on 2014-11-18
2
90 Views
Last Modified: 2014-12-09
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) {
        });
0
Comment
Question by:rbhargaw
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40451243
why not a server side variable ?
0
 

Author Comment

by:rbhargaw
ID: 40451280
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?
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now