mirror of
https://github.com/bastienwirtz/homer.git
synced 2024-10-05 01:42:01 +02:00
fix(message): support API which returns plain text
This commit is contained in:
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
Block a user