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 request.
Implementation
static Future<String> getString(String url,
{bool? withCredentials, void Function(ProgressEvent)? onProgress}) =>
request(url, withCredentials: withCredentials, onProgress: onProgress)
.then((r) => r.responseText);