How to chain func with using Promise.Then?

Run Settings
LanguageJavaScript
Language Version
Run Command
let Query = async function( method, endpoint, options, successCode, obKey ){ //return true; return new Error( 'Could not complete query!' ); }; let isAlive = async function( options ){ try { return await Query( 'GET', '/heart', options, 204 ); } catch( error ){ return error; } }; let getNetworks = async function(options) { try { return await Query( 'GET', '/networks', options, 200, 'networks' ); } catch( error ){ return error; } }; // Standard promise method works isAlive().then( () => { getNetworks().then( result => { console.log( 'GET NETWORKS', result ); }).catch( error => { console.log( 'GET NETWORKS ERROR', error.message ); }); } ); // BUT to make for cleaner code base, how can I only call next function in chain // based on isAlive() function? // isAlive().getNetworks().then( result => { // console.log( 'GET HOMIE NETWORKS', result ); // }).catch( error => { // console.log( 'GET HOMIE NETWORKS ERROR', error.message ); // });
Editor Settings
Theme
Key bindings
Full width
Lines