Welcome: loadDevices 错误信息显示HTTP状态码
This commit is contained in:
@ -237,7 +237,7 @@ async function loadDevices() {
|
||||
document.getElementById('sys-status').textContent = '\u2705 运行中';
|
||||
try {
|
||||
var r = await api('GET', '/api/states');
|
||||
if (!r.ok) throw new Error('获取设备失败');
|
||||
if (!r.ok) throw new Error('HTTP ' + r.status + ' ' + r.statusText);
|
||||
var states = await r.json();
|
||||
document.getElementById('dev-count').textContent = states.length + ' 个实体';
|
||||
|
||||
@ -247,7 +247,7 @@ async function loadDevices() {
|
||||
});
|
||||
document.getElementById('dev-list').innerHTML = html || '<div class="msg">暂无设备,接入硬件后自动发现</div>';
|
||||
} catch(e) {
|
||||
document.getElementById('sys-status').textContent = '\u274c 连接失败';
|
||||
document.getElementById('sys-status').textContent = '\u274c ' + e.message;
|
||||
document.getElementById('dev-list').innerHTML = '<div class="msg error">' + e.message + '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user