174
rated 0 times
[
177]
[
3]
/ answers: 1 / hits: 11690
/ 3 Years ago, mon, november 30, 2020, 12:00:00
Below is my code, in this I want to add code to display all the products with its image from an API, how can I do that? Please help?
import React, {useState, useEffect} from 'react'
import "bootstrap/dist/css/bootstrap.min.css"
import Axios from "axios"
function Products() {
const [products, setProducts] = useState({});
const fetchProducts = async () => {
const {data} = await Axios.get('https://api.test.ts/demo/test');
const products= data
setProducts(products);
};
useEffect(() => {
fetchProducts()
}, []);
return(
<div>
Want to Display list of products from API
</div>
)
}
export default Products;
More From » html