/ask POST, and other fixes

This commit is contained in:
mrfry 2020-12-19 12:47:06 +01:00
parent 19b8fdc5ab
commit c6da65ce40
3 changed files with 119 additions and 58 deletions

View file

@ -403,11 +403,21 @@ function prepareQuestion(
data: string | QuestionData
): Question {
let preparedQuestion: Question
if (typeof question === 'object') {
preparedQuestion = question
} else {
// FIXME data was checkedif its null, it should be never null. check if its really never null
const parsedData = typeof data === 'object' ? data : JSON.parse(data) // TODO: put in try?
let parsedData
if (typeof data === 'string') {
try {
parsedData = JSON.parse(data)
} catch (err) {
// asd
}
}
if (typeof data === 'object') {
parsedData = data
}
preparedQuestion = createQuestion(question, null, parsedData)
}