feat: เพิ่ม params ใน fetchList
This commit is contained in:
parent
42d380b13d
commit
54482648d4
1 changed files with 17 additions and 7 deletions
|
|
@ -52,21 +52,31 @@ const useBranchStore = defineStore('api-branch', () => {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchById(
|
async function fetchById<T extends Branch>(
|
||||||
id: string,
|
id: string,
|
||||||
|
opts?: { includeSubBranch?: boolean },
|
||||||
flow?: {
|
flow?: {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
refTransactionId: string;
|
refTransactionId: string;
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const res = await api.get<Branch>(`/branch/${id}`, {
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
if (opts?.includeSubBranch) params.append('includeSubBranch', 'true');
|
||||||
|
|
||||||
|
const query = params.toString();
|
||||||
|
|
||||||
|
const res = await api.get<T>(
|
||||||
|
`/branch/${id}${(params && '?'.concat(query)) || ''}`,
|
||||||
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Session-Id': flow?.sessionId,
|
||||||
'X-Rtid': flow?.refTransactionId,
|
'X-Rtid': flow?.refTransactionId,
|
||||||
'X-Tid': flow?.transactionId,
|
'X-Tid': flow?.transactionId,
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
if (res.status === 200) return res.data;
|
if (res.status === 200) return res.data;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue