UNPKG

rollbar

Version:

Effortlessly track and debug errors in your JavaScript applications with Rollbar. This package includes advanced error tracking features and an intuitive interface to help you identify and fix issues more quickly.

34 lines (28 loc) 823 B
const { get } = require('https'); const ENDPOINT = 'https://nodejs.org/dist/index.json'; function requestVersionInfo(url) { return new Promise((resolve, reject) => { get(url, response => { let data = ''; response.on('data', chunk => data += chunk); response.on('end', () => resolve(data)); }).on('error', error => reject(new Error(error))); }); } function extractVersionInfo(json) { return JSON.parse(json).map(({ version, npm = null }) => { return { nodejs: version.replace(/^v/, ''), npm }; }); } (async function logVersionInfo() { try { const json = await requestVersionInfo(ENDPOINT); const versionInfo = extractVersionInfo(json); console.log(JSON.stringify(versionInfo, null, 2)); } catch ({ message }) { console.error(message); } })();