react two axios request at the same time or useEffect
Sat Feb 26 2022 02:44:11 GMT+0000 (Coordinated Universal Time)
Saved by
@ruperto1
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);
content_copyCOPY
Comments