Skip to content

Commit

Permalink
fix(dcellar-web-ui): fix the issue with browser cache getObjectMeta API
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed May 11, 2024
1 parent 61d1194 commit 62ce277
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,22 +621,30 @@ export const getObjectMeta = async (
objectName,
)}?object-meta`;

return axios.get(url).then(
(e) => {
const data = xmlParser.parse(e.data)?.GfSpGetObjectMetaResponse.Object as ObjectMeta;
return [data, null];
},
(e) => {
const { response } = e;
if (!response) return [null, { code: 500, message: 'Oops, something went wrong' }];

const error =
response?.status === 429
? { code: response.status, message: 'SP not available. Try later.' }
: { message: xmlParser.parse(response.data)?.Error?.Message, code: response.status };
return [null, error];
},
);
return axios
.get(url, {
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
})
.then(
(e) => {
const data = xmlParser.parse(e.data)?.GfSpGetObjectMetaResponse.Object as ObjectMeta;
return [data, null];
},
(e) => {
const { response } = e;
if (!response) return [null, { code: 500, message: 'Oops, something went wrong' }];

const error =
response?.status === 429
? { code: response.status, message: 'SP not available. Try later.' }
: { message: xmlParser.parse(response.data)?.Error?.Message, code: response.status };
return [null, error];
},
);
};

export const getObjectVersions = async (id: string): Promise<ObjectVersion[]> => {
Expand Down

0 comments on commit 62ce277

Please sign in to comment.