If you want to get the same result from inside node.js or the browser use this.
Im using the personal_listWallets JSON-RPC method in a waitable promise'ify function.
Just call listWallets().then();
async function listWallets() {
try {
const result = await sendRPC_personal_listWallets();
return result;
} catch (e) {
return e;
}
}
function sendRPC_personal_listWallets() {
return new Promise((resolve, reject) => {
web3.currentProvider.send({ method: "personal_listWallets", params: [], jsonrpc: "2.0", id: new Date().getTime() },
function (error, result) { if (error) { reject(error); } else { resolve(result); } });
}
);
}
let wallets;
listWallets().then((r) => { console.log("ID:", r.id); wallets = r.result; console.log("Accounts:", wallets); });