Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138249

WHM API: Getting output JSON elements in a random order each time

$
0
0

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);
    })

Viewing all articles
Browse latest Browse all 138249

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>