mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
/ask POST, and other fixes
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user