Solved

Different Env API end points AngularJS

Posted on 2014-11-18
2
92 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 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

21 Experts available now in Live!

Get 1:1 Help Now