| Index: src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart
|
| diff --git a/src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart b/src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2cadceffb209f09ae382e37771b4f650060c2a3a
|
| --- /dev/null
|
| +++ b/src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart
|
| @@ -0,0 +1,28 @@
|
| +import 'dart:html';
|
| +import 'dart:json' as json;
|
| +import 'dart:async';
|
| +
|
| +var wordList;
|
| +
|
| +void main() {
|
| + query('#getWords').onClick.listen(makeRequest);
|
| + wordList = query('#wordList');
|
| +}
|
| +
|
| +void makeRequest(Event e) {
|
| + var path = 'portmanteaux_simple.json';
|
| + HttpRequest.getString(path)
|
| + .then(processString)
|
| + .catchError(handleError);
|
| +}
|
| +
|
| +processString(String jsonString) {
|
| + List<String> portmanteaux = json.parse(jsonString);
|
| + for (int i = 0; i < portmanteaux.length; i++) {
|
| + wordList.children.add(new LIElement()..text = portmanteaux[i]);
|
| + }
|
| +}
|
| +
|
| +handleError(Error error) {
|
| + wordList.children.add(new LIElement()..text = 'Request failed.');
|
| +}
|
|
|