UNPKG

@constructor-io/constructorio-connect-cli

Version:

CLI tool to enable users to interface with the Constructor Connect Ecosystem

31 lines (30 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getConnections = getConnections; const axios_1 = require("axios"); const errors_1 = require("@oclif/core/errors"); const ux_action_1 = require("../helpers/ux-action"); const http_client_1 = require("./http-client"); async function getConnections({ showLogs, }) { const client = await (0, http_client_1.getHttpClient)(); const fetchConnections = async () => { return await client.get("/connections"); }; try { let response; if (showLogs) { response = await (0, ux_action_1.uxAction)("📡 Fetching your account details", fetchConnections)(); } else { response = await fetchConnections(); } return response.data.connections; } catch (error) { if ((0, axios_1.isAxiosError)(error) && error.response) { throw new errors_1.CLIError("Something went wrong while fetching your company's connections: \n" + error.message); } throw error; } }