Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!