const https = require('https'); const agent = new https.Agent({ rejectUnauthorized: false }); fetch('https://localhost:8443/fineract-provider/api/v1/authentication?username=mifos&password=password&tenantIdentifier=default', { method: 'POST', agent: agent }).then(res => res.json()).then(data => { const token = data.base64EncodedAuthenticationKey; return fetch('https://localhost:8443/fineract-provider/api/v1/clients/9/accounts?tenantIdentifier=default', { headers: { 'Authorization': 'Basic ' + token, 'Fineract-Platform-TenantId': 'default' }, agent: agent }); }).then(res => res.json()).then(data => { console.log(JSON.stringify(data, null, 2)); }).catch(console.error);