Skip to content

Instantly share code, notes, and snippets.

@YounglanHong
Last active October 12, 2020 19:07
Show Gist options
  • Save YounglanHong/8d7eac99096ad11f8df6395ddaa4e138 to your computer and use it in GitHub Desktop.
Save YounglanHong/8d7eac99096ad11f8df6395ddaa4e138 to your computer and use it in GitHub Desktop.
import axios from "axios";
export const SHOW_CARD = "SHOW_CARD";
// 서버로부터 카드 데이터 가져오기
export function getDeckCards() {
return dispatch => {
axios
.get("http://localhost:4000/card/cardInfo")
.then(res => {
dispatch(showCard(res.data));
})
.catch(error => {
console.log(error);
});
};
}
// 서버로부터 받은 카드 데이터를 reducer에서 SHOW_CARD 작업으로 처리
export function showCard(cards) {
return {
type: SHOW_CARD,
cards: cards
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment