Open Valloric opened 10 years ago
Added Area-Library, Library-Html, Triaged labels.
This Dart tutorial also uses getString to fetch JSON data: https://www.dartlang.org/docs/tutorials/fetchdata/
The docs for getString are incorrect. It will happily succeed even if the content type is image/png and give you a bunch of characters. I'm not sure which encoding it's applying, but it should be fine for JSON text.
Removed Type-Defect label. Added Type-Documentation, Accepted labels.
I'm currently getting error to console as getString now expects XML somehow by default
It seems all is either responseType fault or browser bug. See #47743 where I describe my issue (pretty similar though)
Headline doc entry for HttpRequest: https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:html.HttpRequest
> The simplest way to get the contents of a text file, such as a JSON-formatted file, is with getString. [example follows]
Docs for getString (same page):
> The server response must be a text/ mime type for this request to succeed.
Official mimetype for JSON: http://en.wikipedia.org/wiki/JSON#MIME_type
> The official MIME type for JSON text is "application/json".
These three facts put together make zero sense. Either getString should work with responses that aren't "text/" (makes the most sense), or the docs shouldn't recommend the use of this method for JSON.