mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Fix json detect (#1391)
* Fix json detect Content-type is not always "application/json" when using nginx. eg: application/json; charset=utf-8 * Update hass-call-api.js * Lint * Lint 2
This commit is contained in:
parent
c0ae7d50ad
commit
d299166f2a
@ -12,9 +12,10 @@ export default function hassCallApi(host, auth, method, path, parameters) {
|
||||
}
|
||||
|
||||
req.onload = function () {
|
||||
var body = req.responseText;
|
||||
let body = req.responseText;
|
||||
const contentType = req.getResponseHeader('content-type');
|
||||
|
||||
if (req.getResponseHeader('content-type') === 'application/json') {
|
||||
if (contentType && contentType.indexOf('application/json') !== -1) {
|
||||
try {
|
||||
body = JSON.parse(req.responseText);
|
||||
} catch (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user