mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-22 22:05:18 +01:00
Fix: openwrt widget handle null id in json rpc responses and cpu load representation (#3576)
This commit is contained in:
parent
ccc27142ef
commit
9803ef70c6
@ -31,6 +31,10 @@ export async function sendJsonRpcRequest(url, method, params, username, password
|
|||||||
if (status === 200) {
|
if (status === 200) {
|
||||||
const json = JSON.parse(data.toString());
|
const json = JSON.parse(data.toString());
|
||||||
|
|
||||||
|
if (json.id === null) {
|
||||||
|
json.id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// in order to get access to the underlying error object in the JSON response
|
// in order to get access to the underlying error object in the JSON response
|
||||||
// you must set `result` equal to undefined
|
// you must set `result` equal to undefined
|
||||||
if (json.error && json.result === null) {
|
if (json.error && json.result === null) {
|
||||||
|
@ -77,7 +77,7 @@ async function fetchSystem(url) {
|
|||||||
const systemResponse = JSON.parse(data.toString())[1];
|
const systemResponse = JSON.parse(data.toString())[1];
|
||||||
const response = {
|
const response = {
|
||||||
uptime: systemResponse.uptime,
|
uptime: systemResponse.uptime,
|
||||||
cpuLoad: systemResponse.load[1],
|
cpuLoad: (systemResponse.load[1] / 65536.0).toFixed(2),
|
||||||
};
|
};
|
||||||
return [200, contentType, response];
|
return [200, contentType, response];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user