getVideos method
get avaiable videos for a url
from pixabay
Implementation
getVideos(String url) async {
// setup Http Get
HttpClient httpClient = HttpClient();
HttpClientRequest request = await httpClient.getUrl(Uri.parse(url));
HttpClientResponse response = await request.close();
// Process the response.
if (response.statusCode == 200) {
// response: OK
// decode JSON
String json = await utf8.decoder.bind(response).join();
return json;
} else {
// something went wrong :(
print("Http error: ${response.statusCode}");
return [];
}
}