@go-avro/avro-js 0.0.4-beta.38 → 0.0.4-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,6 +28,11 @@ AvroQueryClient.prototype._fetch = async function (method, path, body, cancelTok
|
|
|
28
28
|
};
|
|
29
29
|
const response = await fetch(url, options);
|
|
30
30
|
if (response.ok) {
|
|
31
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
32
|
+
if (contentType.includes('application/pdf') ||
|
|
33
|
+
contentType.includes('application/octet-stream')) {
|
|
34
|
+
return response.blob();
|
|
35
|
+
}
|
|
31
36
|
const text = await response.text();
|
|
32
37
|
if (!text) {
|
|
33
38
|
return undefined;
|
package/dist/client/core/xhr.js
CHANGED
|
@@ -22,6 +22,12 @@ AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken
|
|
|
22
22
|
xhr.onload = () => {
|
|
23
23
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
24
24
|
try {
|
|
25
|
+
const contentType = xhr.getResponseHeader('content-type') || '';
|
|
26
|
+
if (contentType.includes('application/pdf') ||
|
|
27
|
+
contentType.includes('application/octet-stream')) {
|
|
28
|
+
resolve(xhr.response);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
25
31
|
const responseText = xhr.responseText;
|
|
26
32
|
if (!responseText) {
|
|
27
33
|
return resolve(undefined);
|
|
@@ -56,6 +62,12 @@ AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken
|
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
64
|
}
|
|
65
|
+
// Set responseType to 'blob' if expecting binary
|
|
66
|
+
const contentType = headers['Content-Type'] || '';
|
|
67
|
+
if (contentType.includes('application/pdf') ||
|
|
68
|
+
contentType.includes('application/octet-stream')) {
|
|
69
|
+
xhr.responseType = 'blob';
|
|
70
|
+
}
|
|
59
71
|
xhr.send(body);
|
|
60
72
|
});
|
|
61
73
|
return result;
|
|
@@ -170,6 +170,6 @@ AvroQueryClient.prototype.generatePDFFromBackend = function ({ billId }) {
|
|
|
170
170
|
return response;
|
|
171
171
|
});
|
|
172
172
|
};
|
|
173
|
-
AvroQueryClient.prototype.sendBillingEmail = function ({ subject, billId, recipients, }) {
|
|
173
|
+
AvroQueryClient.prototype.sendBillingEmail = async function ({ subject, billId, recipients, }) {
|
|
174
174
|
return this.post(`/bill/${billId}/email`, JSON.stringify({ recipients, subject }), undefined, { "Content-Type": "application/json" });
|
|
175
175
|
};
|