Hi,
How can I access environment variables which are being passed to Node red docker container via. shell script, in the HTML file of a custom node. In HTML file I need to make Ajax calls to get data from API that will be displayed in dropdown as shown below.
I tried $env('API_BASE_URL'), process.env.API_BASE_URL but it doesn't work. Flow and context are unavailable too. Kindly help.
RED.nodes.registerType('some node', { category: 'custom', color: '#a6bbcf', defaults: { name: { value: "" }, source: { value: "", required: true }, }, inputs: 1, outputs: 1, icon: "amazon.png", label: function () { return this.name || " : custom node"; }, oneditprepare: function () { var node = this; var source = node.source || []; const api_root = $env('API_BASE_URL'); const api_url = api_root + '/source/'; const token = JSON.parse(localStorage.getItem("auth-tokens"))["access_token"]; //var flowContext = this.context().flow; // var selectedOptionValue = flowContext.get('Id'); $.ajax({ url: api_url, type: 'GET', dataType: 'json', headers: { 'Content-Type': 'application/json;charset=utf-8', "Authorization": "Bearer " + token } }).done(function (json) { $.each(json["data"], function (i, option) { $('#node-input-source-select').append($('').attr("value", option.id).text(option.name)); }); }).fail(function (xhr) { // handle request failures var errorMessage = xhr.status + ': ' + xhr.statusText; console.log(errorMessage); valid = false; }); },