I am working on the quiz app https://mcqpsm.online/ trying to achieve quiz count- how many times quiz have been taken, data comes from the back4app backend. it works fine until I have 50 total quizzes, now app breaks with the error as no of quiz increased to 59. everything works fine except the in quiz preview https://mcqpsm.online/browse it throws error that unexpected end of json input.
I tried console.log error and found that it is this code throwing error
export async function getQuizzes() {
const quizzes = (await api.get(host + '/classes/Quiz')).results; // empty array if none
const timesTaken = quizzes.length ? await getSolutionsCount(quizzes.map((q) => q.objectId)) : null;
quizzes.forEach((q) => (q.taken = timesTaken[q.objectId]));
return quizzes.length ? quizzes : null;
}
when I comment out the it works fine:
// const timesTaken = quizzes.length ? await getSolutionsCount(quizzes.map((q) => q.objectId)) : null;
// quizzes.forEach((q) => (q.taken = timesTaken[q.objectId]));
but now it does not shows how many times quiz taken

function for quiz count is as follows
export async function getSolutionsCount(quizIds) {
const query = JSON.stringify({ $or: quizIds.map((id) => ({ quiz: createPointer('Quiz', id) })) });
const solutions = (await api.get(host + '/classes/Solution?where=' + encodeURIComponent(query))).results; // empty array if none
if (solutions.length === 0) {
return quizIds.reduce((a, c) => {
if (!a[c]) {
a[c] = 0;
}
return a;
}, {});
}
return solutions.reduce((a, c) => {
const id = c.quiz.objectId;
if (!a[id]) {
a[id] = 0;
}
a[id]++;
return a;
}, {});
}
thanks in advance !