웹화면에서 카드섹션들을 불러오지 못해서 혹시나 하고 강사님 목서버 주소로 입력하니 카드 섹션들이 불려와집니다.
axios.get("주소")
다른 모든 코드들은 강사님과 동일합니다.
터미널에는 이런게 뜹니다.----------------------------
Line 25:11: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
Line 30:11: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
Line 38:19: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
Line 44:21: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
-----------------------------------------------------
혹시나 해서 postman 서버에 들어가보니 respond를 못하는거 같더라구요.
postman 강의때는 잘 불러와졌었는데
혹시 제가 놓친 부분이 있거나 예상되는 오류가 있으실까요?
postman에서 설정을 따로 해야하는 부분이 있나요?
--------------------------------------------------
import React from "react";
import "./index.css";
import axios from "axios";
function MainPage() {
const [products, setProducts] = React.useState([]);
React.useEffect(function () {
axios
.get(
"https://37925d61-5832-477c-9c96-71e279b08d78.mock.pstmn.io/products"
)
.then(function (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;