Created
August 31, 2020 21:23
-
-
Save Javiani/0e3585228ad22f09f6fa35ea4cf37f62 to your computer and use it in GitHub Desktop.
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
export const request = async ( type ) => { | |
const endpoint = endpoints[ type ] || type | |
const results = await requestEndpoint([], { endpoint, offset: null }) | |
return results | |
} | |
const requestEndpoint = async ( list = [], { endpoint, offset } ) => { | |
if ( list.length && !offset ) | |
return list | |
const { data } = await http.get('', { params: { endpoint, offset } }) | |
const config = { endpoint, offset: data.offset } | |
return requestEndpoint([ ...list, ...Records(data)], config ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment