getString static method
Creates a GET request for the specified url
.
This is similar to request but specialized for HTTP GET requests which return text content.
To add query parameters, append them to the url
following a ?
,
joining each key to its value with =
and separating key-value pairs with
&
.
var name = Uri.encodeQueryComponent('John');
var id = Uri.encodeQueryComponent('42');
HttpRequest.getString('users.json?name=$name&id=$id')
.then((String resp) {
// Do something with the response.
});
See also:
Implementation
static Future<String> getString(String url,
{bool? withCredentials, void onProgress(ProgressEvent e)?}) {
return request(url,
withCredentials: withCredentials, onProgress: onProgress)
.then((HttpRequest xhr) => xhr.responseText!);
}