본문으로 건너뛰기

getGroupId

앱인토스 플랫폼에서 발급하는 그룹 ID를 동기적으로 반환합니다. 그룹 ID는 미니앱이 속한 비즈니스 또는 서비스 그룹을 식별하는 데 사용됩니다.

시그니처

import { getGroupId } from '@apps-in-toss/web-framework';

declare function getGroupId(): string;

파라미터

없음.

반환값

  • string — 앱인토스에서 제공하는 그룹 ID 문자열.

권한

권한이 필요하지 않습니다 — getGroupId는 별도의 PermissionName에 바인딩되지 않습니다. 권한이 필요한 다른 네임스페이스의 일반적인 처리 흐름은 Guides — 권한 처리 패턴을 참고하세요.

예제

최소 예제

import { getGroupId } from '@apps-in-toss/web-framework';

const groupId = getGroupId();
console.log('Group ID:', groupId);

실전 예제 — 그룹 ID를 API 요청 헤더에 포함하기

import { getGroupId } from '@apps-in-toss/web-framework';
import { useEffect, useState } from 'react';

function GroupInfoPage() {
const [groupId, setGroupId] = useState('');

useEffect(() => {
const id = getGroupId();
setGroupId(id);
}, []);

async function fetchGroupData() {
const id = getGroupId();
const response = await fetch('/api/group-data', {
headers: {
'X-Group-Id': id,
},
});
return response.json();
}

return (
<div>
<p>그룹 ID: <code>{groupId || '불러오는 중...'}</code></p>
<button type="button" onClick={fetchGroupData}>그룹 데이터 조회</button>
</div>
);
}

직접 실행해 보기

sdk-example의 Environment 페이지에서 getGroupId 카드를 실행해 결과를 확인할 수 있습니다.

sdk-example에서 실행해 보기

관련 API

관련 가이드

외부 참조