fetch와 axios의 장단점
react로 작업을 할때면 습관처럼 axios를 함께 설치하곤 했다. axios를 쓰는 나만의 이유는 없었지만 굳이 생각해보자면 fetch보다 왠지 좀 더 간단한 코드인 것 같아서? 그럼 axios는 fetch와 뭐가 다를까? 왜 굳이 설치하여 사용할까? fetch fetch는 ES6부터 들어온 JavaScript 내장 라이브러리로 따로 설치하지 않고 사용할 수 있다. Promise기반으로 만들어졌기 때문에 axios처럼 다루기가 쉽다. class Youtube { constructor(key) { this.key = key; this.getRequestOptions = { method: "GET", redirect: "follow", }; } async mostPopular() { const respo..
react
2022. 11. 22. 13:48