'Having issues getting data from api call [closed]

Hey guys Im making a api call and getting a response I have not yet encountered . my api call is basic and looks like

async function getStudents(){
          const response = await fetch('url');
          const studentData = response.json();
    
         console.log(studentData)

Promise { : "pending" } : "fulfilled" : Object { students: (25) […] }

and these are the results I get, Normally I could do something like studentData.students to get that object but nothing seems to get the correct object. what am I doing wroing?



Solution 1:[1]

Use something like this :

async function getStudents(){
   fetch('url')
  .then(response => response.json())
  .then(data => console.log(data));
  .catch(error=>console.log(error,"error  occured"));

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hritik Sharma