Skip to content

Instantly share code, notes, and snippets.

@rootsec1
Last active June 28, 2019 08:12
Show Gist options
  • Save rootsec1/22b271265e44509dde743eb14dcb39e5 to your computer and use it in GitHub Desktop.
Save rootsec1/22b271265e44509dde743eb14dcb39e5 to your computer and use it in GitHub Desktop.
[Dart] HTTP GET(ing) a cloud function
import 'dart:io';
import 'dart:convert';
class HttpRequestClass {
void fetchAndDisplay() {
HttpClient()
.getUrl(Uri.parse('https://us-central1-hunt-primary.cloudfunctions.net/pruoo?n=5'))
.then((request) => request.close())
.then((response) => response.transform(Utf8Decoder()).listen(print));
}
}
void main() {
HttpRequestClass httpRequestClass = new HttpRequestClass();
httpRequestClass.fetchAndDisplay();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment