You often need to make changes on a live site (open-heart-surgery) without affecting the users. For this, you should have two copies of the API Controller - one live, and one staging. This is done by doing the following:
- Place the live, tested controller in
/live/api/
and make sure your JavaScript accesses this
- Place a copy in
/staging/api/
or something similar (you can use other path names as well) and make your development JavaScript access that endpoint
- Then you can develop without hurting the live output.
- Once it's stable, you then deploy by copying the new controller to
/live/api/
Click to see the result of the two calls, one to live, one to staging: