import React, { useState, useEffect } from 'react'; import { Link, Redirect } from 'react-router-dom'; import ohuh from '../ohuh.PNG'; import { Container, Row, Form, Image, InputGroup, Button, Col, Card, Nav } from 'react-bootstrap'; import axios from 'axios'; import { handleLogout, isAuthenticated } from '../utils/auth.js' function App() { const [state, setState] = useState(false); const [search, setSearch] = useState(""); const [recommend, setRecommend] = useState([{ name: " ", address: " ", img: " " }]); const [latest, setLatest] = useState([{ name: " ", address: " ", img: " " }]); useEffect(() => { getRecommend() getLatest() }, []); const user = isAuthenticated() if (state !== false) { return ; } const handleChange = (e) => { setSearch(e.target.value); } //바뀌는 것이 있을때 이벤트 발생 const handleSubmit = () => { setState(true); } //submit 버튼을 누르면 state 값을 true로 바뀐다 const getRecommend = () => { axios.get(`/api/app/recommend`) .then(res => { setRecommend(res.data) }) .catch(err => { console.log("APP RECOMMEND ERROR", err) }) } const getLatest = () => { axios.get(`/api/app/lastest`) .then(res => { setLatest(res.data) }) .catch(err => { console.log("APP LATEST ERROR", err) }) } return ( <>
인기관광지 {recommend.name} {recommend.address} 최근 검색 관광지 {latest.name} {latest.address}
); } export default App;