이준호

feat: 서버 통신 코드 수정

import React from 'react';
import './Card.scss';
function Card({data,onClick}){
function Card({data,answer,onClick1,onClick2}){
// type: true false
return(
<>
<div className="card" onClick={onClick}>
<div className="card">
<div className="card__desc">{data.question}</div>
<div className="card__content">{data.answer1}</div>
<div className="card__content">{data.answer2}</div>
<div className="card__content" onClick={onClick1}>{data.answer1}</div>
<div className="card__content" onClick={onClick2}>{data.answer2}</div>
</div>
</>
);
......
......@@ -34,20 +34,29 @@ import "./SurveyPage.scss";
function SurveyPage() {
const [curIdx, setCurIdx] = useState(0);
const [question, setQuestion] = useState([]);
const clickToNext = () =>{
setCurIdx(curIdx+1);
}
const [answer, serAnswer] = useState([]);
// const clickAns1 = (e) =>{
// setCurIdx(curIdx+1);
// const temp
// }
// const clickAns2 = (e) =>{
// setCurIdx(curIdx+1);
// }
useEffect(()=>{
(async () => {
try{
const result = await axios.get("192.168.0.16:8000/getquestions");
setQuestion(result);
console.log(result);
}catch(e){
console.log("서버 통신 실패");
}
})();
const getApi = async() =>{
const apis = axios.create({
baseURL: "",
withCredentials: true
});
const result = await apis.get("http://192.168.0.16:8000/getquestions");
console.log(result);
return result;
}
const data = getApi();
// setQuestion(data);
// console.log(data);
},[]);
return (
......@@ -60,8 +69,10 @@ function SurveyPage() {
<div className="slider__wrapper">
<Card
key={data.num}
data={data}
onClick={clickToNext}
data={data}
// onClick1={clickAns1}
// onClick2={clickAns2}
answer={answer}
style={{
transform: `translateX(${(-30)*curIdx}rem)`,
transition: "0.5s",
......
This diff could not be displayed because it is too large.