Skip to content

Commit

Permalink
Merge pull request #10 from zinen/patch-1
Browse files Browse the repository at this point in the history
Added promise handling of wlan hostList
  • Loading branch information
Salamek authored Apr 25, 2021
2 parents 57ebf09 + 5225945 commit 2e566b1
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/api/WLan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,21 @@ export class WLan extends ApiGroup {
// Make sure Hosts->Host is a list
// It may be returned as a single dict if only one is associated,
// as well as sometimes None.
return this._connection.get('wlan/host-list')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const hosts = <any>this._connection.get('wlan/host-list');
if (!hosts['Hosts']) {
hosts['Hosts'] = {};
}


if (!Object.prototype.hasOwnProperty.call(hosts['Hosts'], 'Host')) {
hosts['Hosts']['Host'] = [];
}

const host = hosts['Hosts']['Host'];
if (host instanceof Array) {
hosts['Hosts']['Host'] = [host]
}

return host;
.then((hosts: any) => {
if (!hosts['Hosts']) {
hosts['Hosts'] = {};
}
if (!Object.prototype.hasOwnProperty.call(hosts['Hosts'], 'Host')) {
hosts['Hosts']['Host'] = [];
}
const host = hosts['Hosts']['Host'];
if (host instanceof Array) {
hosts['Hosts']['Host'] = [host];
}
return host;
})
}

handoverSetting(): Promise<GetResponseType> {
Expand Down

0 comments on commit 2e566b1

Please sign in to comment.