diff --git a/src/components/Operation/Operation.tsx b/src/components/Operation/Operation.tsx index 6402f4136f..c65d2c4833 100644 --- a/src/components/Operation/Operation.tsx +++ b/src/components/Operation/Operation.tsx @@ -163,21 +163,24 @@ export class Operation extends React.Component { setCookieParams(cookieParams); this.setState({ pendingRequest: true }); - fetch(`${appendParamsToPath(path, pathParams, queryParams)}`, request) + const api_url = `${appendParamsToPath(path, pathParams, queryParams)}` + fetch(api_url, request) .then(async (response: any) => { const statusCode = response.status; const statusType = mapStatusCodeToType(statusCode); const isError = statusType === 'error'; const contentType = response.headers.get('content-type'); - if (contentType?.indexOf('application/zip') !== -1 && !isError) { - const slug = last(path?.split('/') || []); + if (contentType && contentType?.indexOf('application/zip') !== -1 && !isError) { + const slug = last(api_url?.split('/') || []); const fileName = slug || 'file'; const bytes = await response.blob(); + const temporaryAnchor = document.createElement('a'); temporaryAnchor.href = URL.createObjectURL(bytes); temporaryAnchor.setAttribute('download', fileName); temporaryAnchor.click(); + this.setState({ response: { type: mapStatusCodeToType(statusCode),