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);
})
Order of JSON elements is not maintained but however JSON array order is maintained. this is the behavior of js
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.