fix(message): support API which returns plain text

This commit is contained in:
Qin Li 2022-11-10 13:39:46 +08:00
parent 6868a0911b
commit 37fcc29d85
No known key found for this signature in database
GPG Key ID: 7A12444CF9D6DD75

View File

@ -67,11 +67,22 @@ export default {
},
downloadMessage: function (url) {
return fetch(url).then(function (response) {
return fetch(url).then(async function (response) {
if (response.status != 200) {
return;
}
return response.json();
const content_type = response.headers.get("Content-Type").split(";")[0];
switch (content_type) {
case "application/json": {
return response.json();
}
case "text/plain": {
return { content: await response.text() };
}
default: {
return response.json();
}
}
});
},