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:
parent
19b8fdc5ab
commit
c6da65ce40
3 changed files with 119 additions and 58 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue