지영이의 개발 블로그
requset 여러개 요청하기 (with Axios multiple request) 본문
두개의 request 처리 하는방법
(Axios의 multiple request)
axios
.all([axios.get('https://codingapple1.github.io/shop/data2.json')
,axios.get('https://codingapple1.github.io/shop/data3.json')])
.then(
axios.spread((res1,res2)=>{
const rest = res1.data;
const resr = res2.data;
const res = [...props.shoes, ...rest, ...resr];
const resp =res.slice(0,6);
props.par(resp);
})
)
두개의 데이터가 형태에 따라 배열로 들어올경우 아래와 같이 한개의 배열로 사용하면 된다.
'코딩 > 유튜브 클론코딩' 카테고리의 다른 글
유튜브 클론코딩 Axios부분 리팩토링 & 환경변수 (0) | 2022.08.05 |
---|---|
fetch api 사용해보기 -선택한비디오 제목 불러오기 (0) | 2022.06.09 |
fetch API를 이용한 REST API 호출 - 검색기능만들기 (0) | 2022.06.09 |
fetch api 사용해보기-데이터 불러오기 (0) | 2022.06.08 |
Youtube API 키 만들고 사용하기 (0) | 2022.05.26 |
Comments