断线重连

This commit is contained in:
紫云徽 2024-09-12 22:39:20 +08:00
parent bc6936def1
commit f10fe2843e

View File

@ -138,8 +138,9 @@ async function connectAPI() {
} }
async function getDHCPList(addr: string | null) { async function getDHCPList(addr: string | null) {
const result = await api.write('/ip/dhcp-server/lease/print');
list = []; list = [];
try {
const result = await api.write('/ip/dhcp-server/lease/print');
for (let eq in result) { for (let eq in result) {
let format = { let format = {
id: result[eq]['.id'], id: result[eq]['.id'],
@ -161,6 +162,14 @@ async function getDHCPList(addr: string | null) {
} }
list.push(format); list.push(format);
} }
} catch (e) {
api = new RouterOSAPI({
host: cfg.host,
user: cfg.user,
password: cfg.password,
});
api.connect();
}
return list; return list;
} }