We are developing a project that heavily interacts with the Spotify API. However, during the development phase, frequent refreshes and numerous API calls are being made which result in hitting the rate limits imposed by Spotify.
To circumvent this issue, an environment-specific configuration should be used to manage API requests based on the environment our application is running in.
The proposed solution is to create a wrapper for the fetch requests and handle it accordingly. Something along these lines:
function fetchAPIData(endpoint) {
if (process.env.ENVIRONMENT === 'development') {
return Promise.resolve(mockData);
}
return fetch(`https://api.spotify.com/v1/${endpoint}`);
}
We are developing a project that heavily interacts with the Spotify API. However, during the development phase, frequent refreshes and numerous API calls are being made which result in hitting the rate limits imposed by Spotify. To circumvent this issue, an environment-specific configuration should be used to manage API requests based on the environment our application is running in.
The proposed solution is to create a wrapper for the fetch requests and handle it accordingly. Something along these lines: