fix: prevent getChatList crash on null API response (#20269)
Add null check before calling .map() on the API response in getChatList(). When the fetch fails silently or returns null, the function now gracefully returns an empty array instead of crashing with 'Cannot read property map of null'.
This commit is contained in:
@@ -142,6 +142,10 @@ export const getChatList = async (
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return res.map((chat) => ({
|
||||
...chat,
|
||||
time_range: getTimeRange(chat.updated_at)
|
||||
|
||||
Reference in New Issue
Block a user