fix(api): handle requests with empty body (user/submit-survey) (#52270)

This commit is contained in:
Oliver Eyton-Williams 2023-11-08 06:18:19 +01:00 committed by GitHub
parent f3749ab7ec
commit f844dd2f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,9 +4,10 @@ const log = debugFactory('fcc:boot:user');
const allowedTitles = ['Foundational C# with Microsoft Survey'];
export function validateSurvey(req, res, next) {
const {
surveyResults: { title = '', responses = [] }
} = req.body;
const { title, responses } = req.body.surveyResults || {
title: '',
responses: []
};
if (
!allowedTitles.includes(title) ||