import React from 'react';
import './index.css';
import axios from "axios";
function MainPage() {
const [products, setProducts]= React.useState([]);
React.useEffect(function() {
axios
.get(
"https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"
)
.then(function(result){
console.log(result);
const products = result.data.products;
setProducts(products);
})
.catch(function(error){
console.error('에러 발생 : ',error);
});
}, []);
return (
<div>
<div id="header">
<div id="header-area">
<img src="images/icons/logo.png" />
</div>
</div>
<div id="body">
<div id="banner">
<img src="images/banners/banner1.png" />
</div>
<h1>판매되는 상품들</h1>
<div id="product-list">
{products.map(function(product, index) {
return (
<div className="product-card">
<div>
<img className="product-img" src={product.imageUrl} />
</div>
<div className="product-contents">
<span className="product-name">{product.name}</span>
<span className="product-price">{product.price}원</span>
<div className="product-seller">
<img
className="product-avatar"
src="images/icons/avatar.png"
/>
<span>{product.seller}</span>
</div>
</div>
</div>
);
})}
</div>
</div>
<div id="footer"></div>
</div>
);
}
export default MainPage;
아 네. postman 과정을 건너뛰었는데요. 바로 이런 문제가 나오네요. 작업후 다시 답변달겠습니다. 감사합니다. ^^