Fix for upload parameters and api client handling of empty responses. AWS put returns no body on a 200 so response.json would mistakenly throw an error
This commit is contained in:
parent
2ff1c7ad28
commit
a7be765bf1
|
@ -88,12 +88,12 @@
|
|||
})
|
||||
loading = true
|
||||
try {
|
||||
const res = await API.externalUpload({
|
||||
const res = await API.externalUpload(
|
||||
datasourceId,
|
||||
bucket,
|
||||
key: processedFileKey,
|
||||
data,
|
||||
})
|
||||
processedFileKey,
|
||||
data
|
||||
)
|
||||
notificationStore.actions.success("File uploaded successfully")
|
||||
loading = false
|
||||
return res
|
||||
|
|
|
@ -163,7 +163,13 @@ export const createAPIClient = (config: APIClientConfig = {}): APIClient => {
|
|||
} else if (parseResponse) {
|
||||
return await parseResponse(response)
|
||||
} else {
|
||||
return (await response.json()) as ResponseT
|
||||
const text = await response.text()
|
||||
// If the response has no body at all e.g s3.put
|
||||
if (!text) {
|
||||
// Empty response
|
||||
return {} as ResponseT
|
||||
}
|
||||
return JSON.parse(text) as ResponseT
|
||||
}
|
||||
} catch (error) {
|
||||
delete cache[url]
|
||||
|
|
Loading…
Reference in New Issue