Conversation
| fetch(url, { | ||
| method: 'GET', | ||
| headers: { | ||
| GoogleToken: googleToken | ||
| } | ||
| }) | ||
| .then(async response => { | ||
| if (!response.ok) { | ||
| const text = await response.text() | ||
| throw new Error(text || `Export failed with status ${response.status}`) | ||
| } | ||
| return response.blob() | ||
| }) | ||
| .then(blob => { | ||
| const downloadUrl = window.URL.createObjectURL(blob) | ||
| const a = document.createElement('a') | ||
| a.href = downloadUrl | ||
| a.download = `bazaar-${props.itemTag}-export.zip` | ||
| document.body.appendChild(a) | ||
| a.click() | ||
| a.remove() | ||
| window.URL.revokeObjectURL(downloadUrl) | ||
| props.onHide() | ||
| }) | ||
| .catch(err => { | ||
| alert('Export failed: ' + err.message) | ||
| }) | ||
| .finally(() => { | ||
| setIsExporting(false) | ||
| }) |
There was a problem hiding this comment.
why do you fetch this manually? We now use our generated API via Tanstack Query
There was a problem hiding this comment.
The generated Orval API code is hardcoded to assume and parse JSON responses, this is a zip download which does not work with the generated API
There was a problem hiding this comment.
You can keep it this way if it work i guess, but is the Swagger defined correctly? If it returns binary it should just return the binary string. At least thats what i would assume
There was a problem hiding this comment.
it seems to be a general orval limitation orval-labs/orval#869
| fetch(url, { | ||
| method: 'GET', | ||
| headers: { | ||
| GoogleToken: googleToken | ||
| } | ||
| }) | ||
| .then(async response => { | ||
| if (!response.ok) { | ||
| const text = await response.text() | ||
| throw new Error(text || `Export failed with status ${response.status}`) | ||
| } | ||
| return response.blob() | ||
| }) | ||
| .then(blob => { | ||
| const downloadUrl = window.URL.createObjectURL(blob) | ||
| const a = document.createElement('a') | ||
| a.href = downloadUrl | ||
| a.download = `bazaar-${props.itemTag}-export.zip` | ||
| document.body.appendChild(a) | ||
| a.click() | ||
| a.remove() | ||
| window.URL.revokeObjectURL(downloadUrl) | ||
| props.onHide() | ||
| }) | ||
| .catch(err => { | ||
| alert('Export failed: ' + err.message) | ||
| }) | ||
| .finally(() => { | ||
| setIsExporting(false) | ||
| }) |
There was a problem hiding this comment.
You can keep it this way if it work i guess, but is the Swagger defined correctly? If it returns binary it should just return the binary string. At least thats what i would assume
|
@Ekwav You can either take another look at the binary response or just merge it :) |
fixes #1477