getNodeList method Null safety
- String endpoint
Query the node infos @param {String} The endpoint Returns the Node infos
Implementation
Future<NodesResponse> getNodeList(String endpoint) async {
final Completer<NodesResponse> _completer = Completer<NodesResponse>();
NodesResponse nodesResponse = NodesResponse();
final Map<String, String> requestHeaders = {
'Content-type': 'application/json',
'Accept': 'application/json',
};
try {
const String _body =
'{"query": "query {nodes {authorized available averageAvailability firstPublicKey geoPatch ip lastPublicKey networkPatch port rewardAddress}}"}';
print(_body);
final http.Response responseHttp = await http.post(
Uri.parse(endpoint + '/api'),
body: _body,
headers: requestHeaders);
print(responseHttp.body);
if (responseHttp.statusCode == 200) {
nodesResponse = nodesResponseFromJson(responseHttp.body);
}
} catch (e) {
print('error: ' + e.toString());
}
_completer.complete(nodesResponse);
return _completer.future;
}