Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
unexpected end of the JSON endpoint

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 enter image description here

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 !

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda