fetchFavoritePosts method

Future<List<ReportModel>> fetchFavoritePosts(
  1. dynamic currentUserId,
  2. dynamic saveId
)

Implementation

Future<List<ReportModel>> fetchFavoritePosts(currentUserId, saveId) async {
  Log(
    logName: 'FetchFavoritePosts',
    className: 'Post',
    methodName: 'fetchFavoritePosts',
    type: 'INFO',
    text:
        '{event: Fetch Favorite Posts, user: ${currentUser?.userPayloadId}, user is ${currentUser?.firstName} ${currentUser?.lastName}, user id: $currentUserId save id: $saveId',
  );
  return _httpService
      .fetchFavoritePosts(currentUserId, saveId)
      .then((data) async {
    if (data.statusCode == 200) {
      List<dynamic> posts = json.decode(data.body);
      List<ReportModel> postsList =
          posts.map((i) => ReportModel.fromJson(i)).toList();
      return postsList;
    } else {
      return List<ReportModel>.from([]);
    }
  });
}