callRESTAPI method
callRESTAPI is used when making unauthenticated REST backend calls
Implementation
Future<Response> callRESTAPI({
required String endpoint,
required String method,
Map<String, dynamic>? variables,
}) async {
final Request request = Request(method, this.fromUriOrString(endpoint));
request.body = json.encode(variables);
return Response.fromStream(
await this.send(request).timeout(
const Duration(seconds: kRequestTimeoutSeconds),
onTimeout: () {
final String timeoutInput = json.encode(kTimeoutResponsePayload);
final List<int> body = utf8.encode(timeoutInput);
return StreamedResponse(
ByteStream.fromBytes(body),
408,
headers: this.requestHeaders,
);
},
),
);
}