diff --git a/src/stores/branch/index.ts b/src/stores/branch/index.ts index c2b91b4f..6c13dd48 100644 --- a/src/stores/branch/index.ts +++ b/src/stores/branch/index.ts @@ -52,21 +52,31 @@ const useBranchStore = defineStore('api-branch', () => { return false; } - async function fetchById( + async function fetchById( id: string, + opts?: { includeSubBranch?: boolean }, flow?: { sessionId: string; refTransactionId: string; transactionId: string; }, ) { - const res = await api.get(`/branch/${id}`, { - headers: { - 'X-Session-Id': flow?.sessionId, - 'X-Rtid': flow?.refTransactionId, - 'X-Tid': flow?.transactionId, + const params = new URLSearchParams(); + + if (opts?.includeSubBranch) params.append('includeSubBranch', 'true'); + + const query = params.toString(); + + const res = await api.get( + `/branch/${id}${(params && '?'.concat(query)) || ''}`, + { + headers: { + 'X-Session-Id': flow?.sessionId, + 'X-Rtid': flow?.refTransactionId, + 'X-Tid': flow?.transactionId, + }, }, - }); + ); if (!res) return false; if (res.status === 200) return res.data;