Skip to content

Instantly share code, notes, and snippets.

@Elvis10ten
Last active April 9, 2018 04:32
Show Gist options
  • Save Elvis10ten/ee813a853d80dda0f51090f62221b48e to your computer and use it in GitHub Desktop.
Save Elvis10ten/ee813a853d80dda0f51090f62221b48e to your computer and use it in GitHub Desktop.
Note: 'http.dart' is a composable, Future-based library for making HTTP requests.
Future<List> getCurrencies() async {
String apiUrl = 'https://api.coinmarketcap.com/v1/ticker/?limit=50';
// Make a HTTP GET request to the CoinMarketCap API.
// Await basically pauses execution until the get() function returns a Response
http.Response response = await http.get(apiUrl);
// Using the JSON class to decode the JSON String
return JSON.decode(response.body);
}
@bapspatil
Copy link

JSON is deprecated. I'm now using json instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment