-
);
-}
+};
+
export default Sidebar;
diff --git a/app/lib/utils/api_service.ts b/app/lib/utils/api_service.ts
index 4b24a076..1f2169fc 100644
--- a/app/lib/utils/api_service.ts
+++ b/app/lib/utils/api_service.ts
@@ -174,5 +174,38 @@ export default class ApiService {
}
}
+ /**
+ * Fetches all messages for a specific user.
+ * @param {string} userId - The ID of the user whose messages are to be fetched.
+ * @returns {Promise
} - The array of messages fetched from the API.
+ */
+ static async fetchUserMessages(userId: string): Promise {
+ try {
+ const url = "http://lived-religion-dev.rerum.io/deer-lr/query";
+ const headers = {
+ "Content-Type": "application/json",
+ };
+
+ // Body for the request: fetch messages of type 'message' created by the specified user
+ const body = {
+ type: "message",
+ creator: userId
+ };
+
+ const response = await fetch(url, {
+ method: "POST",
+ headers,
+ body: JSON.stringify(body),
+ });
+
+ const data = await response.json();
+ return data;
+ } catch (error) {
+ console.error("Error fetching user messages:", error);
+ throw error;
+ }
+}
+
+
}
\ No newline at end of file