Last active
March 7, 2021 10:02
-
-
Save akellbl4/86177880aadf6257ed24a7f86ac3c3ce to your computer and use it in GitHub Desktop.
Article: https://itnext.io/fetch-shared-data-in-next-js-with-single-request-833433fa8ed1 Full code: https://github.com/akellbl4/cache-proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { PUBLIC_NEXT_API_URL } = process.env; | |
let citiesRequest; | |
export function fetchCities() { | |
if (!citiesRequest) { | |
citiesRequest = fetch(`${PUBLIC_NEXT_API_URL}/cities`); | |
} | |
return citiesRequest; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment