Метод getString
Создаёт GET-запрос для указанного url.
Это аналогично request, но специализировано для HTTP-GET-запросов, возвращающих текстовое содержимое.
Для добавления параметров запроса добавьте их к url после ?, соединяя каждый ключ со своим значением с помощью = и разделяя пары ключ-значение с помощью &.
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.
}); См. также:
Реализация
static Future<String> getString(String url,
{bool? withCredentials, void onProgress(ProgressEvent e)?}) {
return request(url,
withCredentials: withCredentials, onProgress: onProgress)
.then((HttpRequest xhr) => xhr.responseText!);
}
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-html/HttpRequest/getString.html