Skip to content

Instantly share code, notes, and snippets.

@rweald
Created February 24, 2022 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rweald/07f4d4ae146d475809e123b2a14007a9 to your computer and use it in GitHub Desktop.
Save rweald/07f4d4ae146d475809e123b2a14007a9 to your computer and use it in GitHub Desktop.
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