My angular2 app consuming my backend laravel API in many different components.
I’ve been thinking that in the future, I will need to change the API URL. That means that I will have to change my API URL everywhere (in all components) I have used http get/post method to my API.
Now.. What will be the right way to implement one variable to store the API URL and use it in all of my components?
- A service just to set get the API URL
- One different service for each of my API objects, for example userAPI.service with user-releated API Calls, peopleAPI.service for people-releatd API Calls, gameAPI.service for game-releated API calls etc..
- Anything different that I still don’t know about?