mirror of https://github.com/bastienwirtz/homer
fix(message): support API which returns plain text
parent
6868a0911b
commit
37fcc29d85
|
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue