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

156
Views
Mapping JSON to MUI cards not returning any UI elements or errors

I have the following JSON which I want to map to MUI Cards. I am not getting any error messages but nothing is being displayed. The console.log(questionGroups) only displays the JSON after changing some unrelated code to cause a live reload.

    const [questionGroups, setQuestionGroups] = useState("");

    const fetchQuestionGroups= async () => {
        setQuestionGroups(
            await fetch(`API_LINK`).then((response) => response.json())
        );
        console.log(questionGroups);
    };

    useEffect(() => {
        fetchQuestionGroups();
    }, []);
...
            <Box className={classes.cards}>
                {questionGroups?.displaygroups?.IntakeQuestion?.map((group, groupIndex) => {
                    return (
                        <Card className={classes.card1}>
                            <CardHeader title={group.GroupName} />
                        </Card>
                    );
                })}
            </Box>

This is a sample of my JSON:

{
  "displaygroups": {
    "IntakeQuestions": [
      {
        "GroupId": 11,
        "GroupName": "Group 1",
        "SizingId": null,
        "OwnerName": "Jane Doe",
        "Questions": 0,
        "Answered": null,
        "Validated": null
      }
    ]
  }
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use && instead of ?

<Box className={classes.cards}>
    {questionGroups &&
        questionGroups.displaygroups &&
        questionGroups.displaygroups.IntakeQuestions.map((group, groupIndex) => {
            return (
                <Card className={classes.card1}>
                    <CardHeader title={group.GroupName} />
                </Card>
            );
        })}
</Box>
about 4 years ago · Juan Pablo Isaza Report

0

You need to set the state once the data is available.

const fetchQuestionGroups= async () => {
     const data = await fetch(`API_LINK`)
     const temp  = response.json()
     setQuestionGroups(temp);
     console.log(questionGroups);
  };
about 4 years ago · Juan Pablo Isaza Report
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!