Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- foreach
- Redux store
- 카우치코딩
- redux 사용방법
- line-through
- first-child
- useParams
- 블럭요소
- JavaScript
- toString
- react redux
- redux toolkit
- JSON
- couchcoding
- useEffect
- javascript React
- React state
- Redux
- 콜백함수
- useSearchParams
- React onClick
- db.json
- 자바스크립트배포
- sort
- react
- 협업프로젝트
- 6주포트폴리오
- 자바스크립트
- javascript코딩테스트
- 인라인블럭
Archives
- Today
- Total
개발하는 루루언니
axios 공식 본문
728x90
반응형
get
import axios from 'axios';
//const axios = require('axios'); // legacy way
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
1. import
2. 주소 가져오기
3. then 성공한 데이터 (res) 들어옴 ( 200대)
4. 그걸 바로 사용할수 있음 ( console.log (res)
5. 에러난걸 캐치 할 수 있음 catch ( error) (400대)
Post
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
728x90
'컴퓨터 정보 > 리액트' 카테고리의 다른 글
useLocation (0) | 2022.11.13 |
---|---|
useQuery 공식 (0) | 2022.11.12 |
Tanstack Query 사용해보기 (0) | 2022.11.11 |
outlet 사용하는법 : 페이지 전체를 랜더링 X (0) | 2022.11.11 |
라우팅 vs 클라이언트 사이드 라우팅 (0) | 2022.11.11 |