Skip to content

Commit

Permalink
feat: 질문 리스트 api 연동 완성 (#66)
Browse files Browse the repository at this point in the history
TODO
상세 페이지로 넘어가는 router설정
  • Loading branch information
Lavegaa committed Nov 24, 2020
1 parent c68bbfc commit 2137253
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 5 additions & 7 deletions src/pages/QuestionListPage/IsQuestionList/IsQuestionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const AddText = styled.div`
`;

export default function IsQuestionList({ questionList }) {
const [count, setCount] = useState(QuestionItemMock.length);
return (
<>
<Wrapper>
Expand All @@ -60,12 +59,11 @@ export default function IsQuestionList({ questionList }) {
</AddText>
</AddQuestionList>
</ItemWrapper>
{questionList.map((val) => {
// getQuestionItemAPI(JSON.stringify(val.id).replace(/\\"/g, '')).then((response) => {
// const arr = JSON.parse(JSON.stringify(response.data));
// setCount(arr.length);
// });
console.log(val);
{questionList?.map((val) => {
const [count, setCount] = useState(0);
getQuestionItemAPI(val.id).then((response) => {
setCount(response.data.length);
});
return (
<ItemWrapper>
<QuestionCardView
Expand Down
15 changes: 9 additions & 6 deletions src/pages/QuestionListPage/QuestionListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ const Select = styled.div`

export default function QuestionListPage() {
const authSelector = useSelector(get('auth'));
const [questionList, setQuestionList] = useState(QuestionListMock);
// useEffect(() => {
// getQuestionListAPI().then((response) => {
// setQuestionList(JSON.parse(response.data));
// });
// }, [questionList]);
const [questionList, setQuestionList] = useState();
const fetch = async () => {
getQuestionListAPI().then((response) => {
setQuestionList(response.data);
});
}
useEffect(() => {
fetch();
}, []);

return (
<>
Expand Down
3 changes: 1 addition & 2 deletions src/repository/questionListRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const getQuestionListAPI = async (param) => await api({
});

export const getQuestionItemAPI = async (param) => await api({
url: '/api/self/question',
url: `/api/self/question?listId=${param}`,
type: 'get',
param,
});
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
debug: true,
}],
'@babel/preset-react'],
plugins: ['@babel/plugin-proposal-class-properties'],
plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining'],
},
},
},
Expand Down

0 comments on commit 2137253

Please sign in to comment.