#21 데이터 Flow & Axios
2022. 8. 4. 21:32ㆍTIL/따라하며 배우는 노드 리액트
728x90
[인프런] 따라하며 배우는 노드, 리액트 시리즈 - 기본강의를 들으며 정리한 내용입니다.
1. axious 다운받기
cd client
npm install axios --save
2. LandingPage.js 파일에 axios 구문을 추가해준다.
import React, { useEffect } from "react";
import axios from "axios";
export default function LandingPage() {
useEffect(() => {
axios.get("/api/hello").then((response) => console.log(response.data));
}, []);
return <div>LandingPage</div>;
}
3. server/index.js 파일에 아래 구문 추가하기
app.get("/api/hello", (req, res) => {
res.send("안녕하세요");
});
'TIL > 따라하며 배우는 노드 리액트' 카테고리의 다른 글
#23 Proxy Server란? (0) | 2022.08.04 |
---|---|
#22 CORS 이슈, Proxy 설정 (0) | 2022.08.04 |
#20 React Router Dom (0) | 2022.08.04 |
#19 CRA to Our Boilerplate (0) | 2022.08.04 |
#16 Create-React-App (0) | 2022.08.04 |