인증 헤더, 쿠키 설정

설명
Tags
config

Fetch 함수 분석

fetch(method: Methods, url: string, headers?: { [key: string]: string }, body?: any| null): StatefulPromise<FetchBlobResponse>;

인증토큰 설정

fetch(Method, URL, Header?) 형식이므로 header부분에 Authorization 헤더를 설정할 수 있다.
  • { key: value } 형식으로 전달
// send http request in a new thread (using native code) RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', { Authorization : 'Bearer access-token...', // more headers .. })

쿠키 설정

  • axios, fetch 등 일반적인 js요청에 의해 생성된 쿠키를 자동으로 전달하므로, 쿠키 기반으로 사용자를 인증하는 경우에는 별다른 작업을 할 필요 없다.