Skip to content

Instantly share code, notes, and snippets.

@nelsonsilva
Created April 28, 2014 09:09
Show Gist options
  • Save nelsonsilva/11366271 to your computer and use it in GitHub Desktop.
Save nelsonsilva/11366271 to your computer and use it in GitHub Desktop.
import 'package:http/http.dart' as http;
import 'dart:async';
import 'dart:convert';
import 'dart:io';
Future<Iterable> getGistsForUser(String user) => http.get("https://api.github.com/users/$user/gists")
.then((res) => JSON.decode(res.body).map((e) => e["html_url"]));
prompt(txt) { stdout.write(txt); return stdin.readLineSync(); }
void main() {
var user = prompt('Enter your GitHub username: ');
getGistsForUser(user)
.then((gists) { print(gists.join("\n")); })
.catchError((err) { stderr.writeln("User $user not available"); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment