const [autor, setAutor] = useState({ auth: null });
const [blog, setBlog] = useState({});
let { id } = useParams();
const navigate = useNavigate();
useEffect(() => {
const fetching = async () => {
const { data } = await axios.get(`/api/blogs/${id}`);
const respAuth = await axios(`/api/users/all`);
setAutor({ auth: respAuth.data });
setBlog(data);
};
fetching();
}, [id, setAutor, setBlog]);
console.log("single blog title: ", blog.title);
console.log("Autores: ", autor);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter