Przeglądaj źródła

update report (but sometimes cannot open)

tags/Baseline_30082024_FRONTEND_UAT
cyril.tsui 1 rok temu
rodzic
commit
8771ce179a
2 zmienionych plików z 6 dodań i 6 usunięć
  1. +0
    -2
      src/app/api/reports/actions.ts
  2. +6
    -4
      src/app/utils/fetchUtil.ts

+ 0
- 2
src/app/api/reports/actions.ts Wyświetl plik

@@ -19,7 +19,5 @@ export const fetchEX02ProjectCashFlowReport = async (data: EX02ProjectCashFlowRe
},
);

console.log(reportBlob)

return reportBlob
};

+ 6
- 4
src/app/utils/fetchUtil.ts Wyświetl plik

@@ -16,7 +16,7 @@ export const serverFetch: typeof fetch = async (input, init) => {
...(accessToken
? {
Authorization: `Bearer ${accessToken}`,
Accept: "application/json"
Accept: "application/json, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
: {}),
},
@@ -61,12 +61,14 @@ export async function serverFetchBlob<T>(...args: FetchParams) {
const response = await serverFetch(...args);

if (response.ok) {
console.log(response)
// const blob = await response.blob()
// const blobText = await blob.text();
// const blobType = await blob.type;
const blobValue = (await response.body?.getReader().read())!!.value!!
return {filename: response.headers.get("filename"), blobValue: blobValue} as T;
const readBody = await response.body?.getReader().read()
const bodyValue = readBody!!.value!!
console.log(bodyValue)
return {filename: response.headers.get("filename"), blobValue: bodyValue} as T;
} else {
switch (response.status) {
case 401:


Ładowanie…
Anuluj
Zapisz