export async function _findHost ( ) { return new Promise ( ( resolve , reject ) => { const random = ( arr ) => arr [ Math . floor ( Math . random ( ) * arr . length ) ] ; try { fetch ( 'https://api.audius.co' ) . then ( r => r . json ( ) ) . then ( j => j . data ) . then ( d => resolve ( `${ random ( d ) }/v1` ) ) ; } catch ( error ) { reject ( error ) ; } } ) ; } export function artistSearch ( endpoint , query ) { return fetch ( `${ endpoint }/users/search?query=${ query }&app_name=Nuclear` ) ; } export function getArtist ( endpoint , id ) { return fetch ( `${ endpoint }/users/${ id }?app_name=Nuclear` ) ; } export function getArtistTracks ( endpoint , id ) { return fetch ( `${ endpoint }/users/${ id }/tracks?app_name=Nuclear` ) ; } export function trackSearch ( endpoint , query ) { return fetch ( `${ endpoint }/tracks/search?query=${ query }&app_name=Nuclear` ) ; } export function getTrack ( endpoint , id ) { return fetch ( `${ endpoint }/tracks/${ id }` ) ; }