Fix bug that didn't allow infinity values to be saved

This commit is contained in:
Oskar Winkels 2021-01-23 11:02:11 +01:00
parent c19a7941fa
commit e3a15ac60f
1 changed files with 4 additions and 2 deletions

View File

@ -52,7 +52,7 @@ async function shareQuiz() {
var response = await fetch(db, { var response = await fetch(db, {
method: 'POST', method: 'POST',
headers: {'Content-Type': 'text/plain'}, headers: {'Content-Type': 'text/plain'},
body: JSON.stringify(quizData) body: JSON.stringify(quizData, (k,v) => (v == Infinity) ? '__Infinity' : v)
}) })
if (response.ok == false) { if (response.ok == false) {
@ -92,7 +92,9 @@ async function fetchQuiz(id) {
return return
} }
var json = await response.json() var text = await response.text()
var json = JSON.parse(text, (k,v) => (v == '__Infinity') ? Infinity : v)
console.log('Quiz fetched. Response:') console.log('Quiz fetched. Response:')
console.log(json) console.log(json)