Last active
June 28, 2019 08:12
-
-
Save rootsec1/22b271265e44509dde743eb14dcb39e5 to your computer and use it in GitHub Desktop.
[Dart] HTTP GET(ing) a cloud function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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