Skip to content

Commit

Permalink
Throw if wrong response from project api (#6014)
Browse files Browse the repository at this point in the history
Do not show in changelog
  • Loading branch information
ClementPasteau authored Dec 5, 2023
1 parent 112c306 commit 8be1961
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions newIDE/app/src/Utils/GDevelopServices/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ export const getLastVersionsOfProject = async (
},
params: { userId },
});
return response.data;
const projectVersions = response.data;

if (!Array.isArray(projectVersions)) {
throw new Error('Invalid response from the project versions API');
}

return projectVersions;
};

export const getCredentialsForCloudProject = async (
Expand Down Expand Up @@ -384,7 +390,13 @@ export const listUserCloudProjects = async (
headers: { Authorization: authorizationHeader },
params: { userId },
});
return response.data;
const cloudProjects = response.data;

if (!Array.isArray(cloudProjects)) {
throw new Error('Invalid response from the projects API');
}

return cloudProjects;
};

export const listOtherUserCloudProjects = async (
Expand All @@ -397,7 +409,13 @@ export const listOtherUserCloudProjects = async (
headers: { Authorization: authorizationHeader },
params: { userId },
});
return response.data;
const cloudProjects = response.data;

if (!Array.isArray(cloudProjects)) {
throw new Error('Invalid response from the projects API');
}

return cloudProjects;
};

export const getCloudProject = async (
Expand Down Expand Up @@ -667,5 +685,11 @@ export const listProjectUserAcls = async (
},
params: { userId: currentUserId, projectId },
});
return response.data;
const projectUserAcls = response.data;

if (!Array.isArray(projectUserAcls)) {
throw new Error('Invalid response from the project user acls API');
}

return projectUserAcls;
};

0 comments on commit 8be1961

Please sign in to comment.