Created
February 24, 2022 05:33
-
-
Save rweald/07f4d4ae146d475809e123b2a14007a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import axios from 'axios' | |
const baseUrl = SOME_URL | |
const fetchAllData = async () => { | |
let allData = [] | |
let apiResponse = await axios.get(baseUrl) | |
allData.push(apiResponse.data_you_care_about) | |
while (apiResponse.next_cursor) { | |
apiResponse = await axios.get(baseUrl + `next_cursor=${apiResponse.next_cursor}`) | |
allData.push(apiResponse.data_you_care_about) | |
} | |
return allData | |
} | |
fetchAllData() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment