headers의 'application/json'

Churro.·2022년 1월 7일
2

<Token 기반 인증방식 스프린트 중>
Client측에서 axios를 사용하여 get/post 요청(req)를 하고 res를 server에서 받아오는 과정에서,
헤더를 보내는 정해진 형식이 있다.

Example)

axios.post(
      "https://localhost:5000/signup",
            { email, password, mobile },
            {
              headers: { "Content-Type": "application/json" },
              withCredentials: true,
            }
)

headers: { ‘content-Type': 'application/json' }
headers: { accept: 'application/json' }

이렇게 두가지 방식으로 쓸 수 있는데, 구체적인 차이점이 궁금했다.

두개의 차이점?

Content-Type 헤더와 Accept 헤더 둘 다 데이터 타입(MIME)을 다루는 헤더이지만,
Content-Type 헤더는 현재 전송하는 데이터가 어떤 타입인지에 대한 설명이고,
Accept 헤더는 클라이언트가 서버에게 웬만하면 데이터 전송할때 이러이러한 타입으로 가공해서 보내라 라고 하는 것이라고 이해하면 된다.

profile
I, sum of records.

0개의 댓글