Skip to content

Instantly share code, notes, and snippets.

@larryq
Created March 3, 2021 06:01
Show Gist options
  • Save larryq/864035798573c4eb7fa181096f803dd6 to your computer and use it in GitHub Desktop.
Save larryq/864035798573c4eb7fa181096f803dd6 to your computer and use it in GitHub Desktop.
Future<List<Clip>> fetchClips() async {
List<Clip> clips = [];
final response = await http.get(
"https://api.songclip.com/songclips/?q=love&shuffle=true&page=1&limit=20&minLength=10&maxLength=300",
headers: {
HttpHeaders.authorizationHeader: authHeader,
"apikey": apikey,
},
);
final responseJson = jsonDecode(response.body);
clips = responseJson['data']['songclips']
.map<Clip>((item) => Clip.fromJson(item))
.toList();
return clips;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment