sendRaw()
함수 시그니처
sendRaw: (data?: BodyInit) => DenchCreateBuilder<T>
관련 RequestInit 및 Header 속성
{
headers: {
'Content-Type': 'application/octet-stream',
},
body: data,
}
설명
네이티브 Fetch API가 허용하는 BodyInit 값을 별도의 변환 없이 요청 body로 설정합니다. data를 생략하면 현재 빌더의 config.options.body를 사용합니다.
예제
import { dench } from 'dench-fetch';
const response = await dench('https://api.example.com')
.post('/raw')
.sendRaw('raw body')
.toResponse();
실제 RequestInit과 Header는 다음과 같습니다.
{
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream',
},
body: 'raw body',
}
주의사항
- 데이터는 변환하지 않지만 Content-Type은 항상
application/octet-stream으로 설정합니다. - 텍스트, URL 인코딩 데이터 등 다른 Content-Type이 필요한 데이터에는 해당 형식의 전용 메서드를 사용하세요.
- 현재 실제 구현은
post(api, data)와put(api, data)의 두 번째 인자를 저장하지 않습니다. body는sendRaw(data)에 직접 전달하세요. - 이미 설정된 body와
Content-Type헤더를 덮어씁니다.