I got this code worked on axios “^0.25.0” but got an error on “^0.28” when constructing a Blob
of the response data.
The code:
<--- more codes -->
return new Promise(async (resolve, reject) => {
try {
const response = await axios({
url: result?.source_file,
method: "GET",
responseType: "blob",
});
const blob = new Blob([response.data], { type: "audio/mp3" });
const buffer = await blob.arrayBuffer();
const item: ResultFile = {
audioFileId: audioFile.id,
type: type,
buffer: buffer,
blobType: blob.type,
};
db.resultFiles.add(item);
resolve(blob);
} catch (error) {
this.log.error(error);
reject(error);
}
});
Error:
Type 'AxiosResponse<any, any>' is not assignable to type 'BlobPart'.ts(2322)
const response: AxiosResponse<AxiosResponse<any, any>, any>
I played around with assigning the generic axios<Blob>
, but it doesn’t seem to work. Any pointers?