-
Notifications
You must be signed in to change notification settings - Fork 0
4주차 #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
4주차 #14
Conversation
DeveloperRyou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4주차 과제도 잘 진행해주셨고, 캐러셀 부분 작업중이시다면 pr 주시면 피드백 드리겠습니다!
| const [posts, setPosts] = useState<NoticeCardInterface[]>([]); | ||
| useEffect(() => { | ||
| axios | ||
| .get("https://jsonplaceholder.typicode.com/posts") | ||
| .then((response) => { | ||
| setPosts(response.data); | ||
| console.log("success!", response.data); | ||
| }) | ||
| .catch((error) => { | ||
| console.log("some errors", error); | ||
| }); | ||
| }, []); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [posts, setPosts] = useState<NoticeCardInterface[]>([]);
useEffect(() => {
async function getData() {
try {
const response = await axios.get("https://jsonplaceholder.typicode.com/posts");
setPosts(response.data);
console.log("success!", response.data);
}
catch(error) {
console.log("some errors", error);
});
}
getData();
}, []);
이런식으로 진행할 수 있을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 이런식으로 진행하면 나중에 좋은점이, getData같은 함수를 따로 빼서 관리할 수 있게 됩니다! axios 요청하는 함수를 따로 파일로 관리할 수 있게 되어 유지보수가 수월해 지겠죠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
캐러셀은 알려주신 slick라이브러리 사용해서 잘 마무리 했습니다!
No description provided.