How to get the HTTP response text from a HttpRequest.postFormData's catchError's _XMLHttpRequestProgressEvent? How to get the HTTP response text from a HttpRequest.postFormData's catchError's _XMLHttpRequestProgressEvent? dart dart

How to get the HTTP response text from a HttpRequest.postFormData's catchError's _XMLHttpRequestProgressEvent?


It seems like the target in your error object is actually your HttpRequest.

You may find this link helpful: https://www.dartlang.org/docs/tutorials/forms/#handling-post-requests

You could do something like:

import "dart:html";HttpRequest.postFormData(url, data).then((HttpRequest request) {    request.onReadyStateChange.listen((response) => /* do sth with response */);}).catchError((error) {    print(error.target.responseText); // Current target should be you HttpRequest});