Where should I store settings like API endpoints, API Keys, etc..?

I have several information like api keys, api endpoint url and so on.

What is the best place to store these settings? Should I create a JSON or XML-config file? Or Singleton-class with constant variables?

I’ve found the best thing is to run a data service, as a provider, which is then available across the app if you include it once in the app.js file.

This service can then interact with local storage, so you have three levels of data, variables in your pages, then 1) app-wide data service, then 2) local storage, then 3) server.

Hope that helps, works for me.

1 Like