From 025199770328558e02394137799f17cd9f52dccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pasteau?= <4895034+ClementPasteau@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:34:50 +0100 Subject: [PATCH] Prevent loading announcements in state if response is not an array (#5975) Do not show in changelog --- newIDE/app/src/Utils/GDevelopServices/Announcement.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/newIDE/app/src/Utils/GDevelopServices/Announcement.js b/newIDE/app/src/Utils/GDevelopServices/Announcement.js index 7919ec4c7a73..f0a880ce32cc 100644 --- a/newIDE/app/src/Utils/GDevelopServices/Announcement.js +++ b/newIDE/app/src/Utils/GDevelopServices/Announcement.js @@ -17,5 +17,10 @@ export const listAllAnnouncements = async (): Promise> => { const response = await axios.get( `${GDevelopReleaseApi.baseUrl}/announcement` ); - return response.data; + const announcements = response.data; + if (!Array.isArray(announcements)) { + throw new Error('Invalid response from the announcements API'); + } + + return announcements; };