Node-fetch

공부의 기록·2021년 11월 7일
0

Node.JS

목록 보기
25/32
post-thumbnail

Node-fetch

Fetch 는 가져오다 라는 뜻이다.
Node-Fetch 는 Node.js 안에서 타사 API 의 정보를 가져오기 위한 라이브러리 중 하나이다. 물론 Node.js 런타임에서 호환되는 API 를 가져오는 것이다.

NPM

npm install node-fetch

ISSUE

  1. Native Promise and Async Function
  2. Native Node Stream Used << 무슨 뜻이지?
  3. Decode content, encoding properly...
  4. Convert String output and res.json() to UTF-8 automatically

EXAMPLE

import fetch from "node-fetch";

const data=fetch(`${API_URL}`)
  .then((res)=>res.json())
  .then((json)=>json.name.name);

SUGEEST

Stable 한 프레임워크 거나 많은 기능이 요구 되는 경우에는 Axios 를 사용하자
단, React Native 와 같이 변동성이 높거나 혹은 빠르게 변화하는 프레임워크에 경우에는 Node-fetch 를 통해 안정성을 확보할 수 있을 것이다.

Axios 는 실시간으로 변화를 따라가지 못할 수도 있다 라는 의견을 보았다. 관련문서

profile
2022년 12월 9일 부터 노션 페이지에서 작성을 이어가고 있습니다.

0개의 댓글