UNPKG

n8n-nodes-fxcm

Version:
30 lines (29 loc) 970 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = execute; const FxcmClient_1 = require("../../Fxcm/FxcmClient"); async function execute() { const credentials = await this.getCredentials('fxcmApi'); const fxcmCredentials = { apiToken: credentials.apiToken, apiUrl: credentials.apiUrl, accountType: credentials.accountType, tradingStationId: credentials.tradingStationId, }; const client = new FxcmClient_1.FxcmClient(fxcmCredentials); const instrument = this.getNodeParameter('instrument', 0); try { const prices = await client.getPrices(instrument); return [{ json: prices, }]; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get prices: ${error.message}`); } else { throw new Error('Failed to get prices: Unknown error'); } } }