I am using the fetch api to fetch some data from my own back-end api. As I know fetch gives us a response we must convert it into a json to read the body of the response.The resulting data is in form of json.
fetch(`/user/getFriends?steam64=${dataObj.persondata.steamid}`,{
method:"GET",
})
.then(res=> res.json())
.then((data)=>{
const obj = JSON.parse(data);
const objValues = Object.values(obj);
console.log(typeof objKeys); //object
});
As we can see in the code above.I am converting the json back to object by using JSON.parse and storing it into a variable called 'obj'.Then I am using Object.values(); To extract the values from the object and store it in an array.
But if I check the type of 'objValues' it returns object rather than array. Please help me out.Any help regarding this is greatly appriciated.THANK YOU