I want to fetch product title from fakestoreapi . but why product title shows undefined in console. Here is my code -
import React, { useEffect, useState } from "react";
import axios from "axios";
const Ari = () => {
const [name, setName] = useState([]);
useEffect(() => {
async function getData() {
const res = await axios.get(
"https://fakestoreapi.com/products"
);
setName(res);
console.log(res.data.title);
}
getData();
}, []);
return <>
<h1>nothing to show now</h1>
</>;
};
export default Ari;