Skip to content

bm.call() ​

  • HTTP 요청을 보낼 때 사용할 수 있어요.
  • bm.call(request) 형식으로 사용하며 Promise를 반환해요.
  • 기본 전송 데이터 형식은 JSON(Content-Type: application/json)이에요.
  • 스토어를 구분할 수 있도록 요청 헤더에 스토어 ID(SS-Store-ID)를 포함해 자동으로 전달해요.

⚠️ 서버에서 스토어 ID 헤더(SS-Store-ID)에 대한 CORS 허용이 필요해요

bm.call()로 서버를 호출하면 스토어 ID 헤더(SS-Store-ID)가 자동으로 전송되기 때문에, 서버에서 해당 헤더에 대한 CORS가 허용되어 있어야 해요.

jsx
<script>
	// GET 요청 예시
	bm.call({
		method: 'GET',
		url: 'https://example.org/cats'
	}).then(response => {
		bm.context.cats = response.data;
		bm.apply();
	});

	// POST 요청 예시
	bm.call({
		method: 'POST',
		url: 'https://example.org/dogs',
		data: {
			name: '블로키'
		}
	}).then(response => {
		console.log(response.data);
	});

	// 기본 전송 요청 헤더를 오버라이딩하려는 경우
	bm.call({
		method: 'POST',
		url: 'https://example.org/cats',
		data: '블로키',
		headers: {
			'Content-Type': 'text/plain', // 전송 컨텐츠 타입 변경
			'SS-Store-ID': null           // 스토어 ID 헤더를 명시적으로 미전송 설정
		}
	}).then(response => {
		// ...
	});
</script>

Sixshop Developers Portal