I am using NodeJS to get results through WHM API 1.
I made an async function which calls WHM getdiskusage
function and receives the results object.
The results I get back from the JSON is having its pair of key,values with correct mapping.
However their order is always random.
WHM API 1 getdiskusage() expected order of output result https://documentation.cpanel.net/display/DD/WHM+API+1+Functions+-+getdiskusage
.
var WHM = require('node-whm');
var whmClient = new WHM.Client({
serverUrl: 'https://my.remotehost.com:2087',
remoteAccessKey: 'xxxxxxxxxxxxxxxxxxxxxxxxx',
username: 'xxxxxxxx'
})
async function getDiskInfo() {
try
{
let response = await whmClient.getdiskusage().then(async (token) => { return await token } )
let data = await response
return data
}catch(err){
console.error('Error: ', err);
}
}
getDiskInfo()
.then(data => {
let d = JSON.parse(data)
console.table(d.data.partition)
}).catch(() => {
console.error('Error: ', err);
})