Skip to content

Commit

Permalink
Prevent loading announcements in state if response is not an array
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementPasteau committed Nov 29, 2023
1 parent 57faa9f commit 00c181e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion newIDE/app/src/Utils/GDevelopServices/Announcement.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ export const listAllAnnouncements = async (): Promise<Array<Announcement>> => {
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;
};

0 comments on commit 00c181e

Please sign in to comment.