list method
HTTP Method: GET Returns a JSON payload that acts as a pass-through to the DevTools /json/list HTTP API in Chromium and Chrome. Browserless crafts this payload so that remote clients can connect to the underlying "webSocketDebuggerUrl" properly, excluding any API tokens in that URL. If under authentication be sure to include your authorization. Summary: /json/list
Implementation
Future<List<CDPJSONPayload>> list({dynamic body}) async {
final queryParams = <String, String>{};
if (defaultToken != null) {
queryParams['token'] = defaultToken!;
}
final pathUrl = '/json/list';
final uri = Uri.parse(
'$baseUrl$pathUrl',
).replace(queryParameters: queryParams.isNotEmpty ? queryParams : null);
final request = http.Request('GET', uri);
if (body != null) {
request.headers['Content-Type'] = 'application/json';
request.body = jsonEncode(body);
}
final streamedResponse = await _client.send(request);
final response = await http.Response.fromStream(streamedResponse);
if (response.statusCode != 200 && response.statusCode != 204) {
throw Exception('HTTP ${response.statusCode}: ${response.body}');
}
if (response.statusCode == 204) return [];
return (jsonDecode(response.body) as List)
.map((i) => CDPJSONPayload.fromJson(i))
.toList();
}