getComponent method

Future<PagePropsEntity> getComponent(
  1. String componentName,
  2. String? branchName
)

Implementation

Future<PagePropsEntity> getComponent(
    String componentName, String? branchName) async {
  final res = await _httpClient.post(
    Uri.parse(getComponentApiUrl),
    headers: {
      'Authorization': 'Bearer $_token',
      ...defaultHeaders,
    },
    body: json.encode({
      'component_name': componentName,
      'branch_name': branchName,
    }),
  );

  if (res.statusCode != 200) {
    throw Exception(
      'Error fetching component, code: ${res.statusCode}, message: ${res.body}',
    );
  }
  return PagePropsEntity.fromJson(jsonDecode(utf8.decode(res.bodyBytes)));
}