luci-app-lldpd: Fix mysterious Command failed: Unknown error

Executing the following command:

ubus call luci.lldpd getStatus

always returned 'Command failed: Unknown error', but the underlying

lldpcli -f json0 show *

worked fine. Fixed with a chained ?.read?

Tested on 23.05.3

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald 2024-10-10 22:03:46 +02:00
parent 02f2d47102
commit c40253ada3
1 changed files with 12 additions and 12 deletions

View File

@ -3,11 +3,10 @@
import { popen } from 'fs'; import { popen } from 'fs';
function lldpcli_json(section) { function lldpcli_json(section) {
return json(popen(`lldpcli -f json0 show ${section}`, 'r')); return json(popen(`lldpcli -f json0 show ${section}`, 'r')?.read?.('all'));
} }
return { const methods = {
'luci.lldpd': {
getStatus: { getStatus: {
call: function() { call: function() {
return { return {
@ -18,5 +17,6 @@ return {
}; };
} }
} }
}
}; };
return { 'luci.lldpd': methods };