Cant get environmental key to read in my nodejs program

Cant get environmental key to read in my nodejs program

I have declared a environmental variable in which my console can read. I am now trying to get the environmental variable to read my script.js file so my API key stays secure but it wont read. How can i fix this?

I have declared a environmental variable in which my console can read. I am now trying to get the environmental variable to read my script.js file so my API key stays secure but it wont read. How can i fix this?

The process.env works for a console call in my server.js file but not in this one. Please help me

// Create a request variable and assign a new XMLHttpRequest object to it.
var request = new XMLHttpRequest();


// Open a new connection, using the GET request on the URL endpoint

request.open('GET', 'https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/testname?api_key=' + process.env.API_KEY, true);

request.onload = function () {

// Begin accessing JSON data here }

// Send request request.send();


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Create a Fake REST API Server using Node.js

How to make a REST API Server using Node.js for testing your AJAX client side.

Build a REST API using Node.js, Express.js, Mongoose.js and MongoDB

Node.js, Express.js, Mongoose.js, and MongoDB is a great combination for building easy and fast REST API. You will see how fast that combination than other existing frameworks because of Node.js is a packaged compilation of Google’s V8 JavaScript engine and it works on non-blocking and event-driven I/O. Express.js is a Javascript web server that has a complete function of web development including REST API.

Node.js API Tutorial for Beginners - Building API using NodeJS

Learn Node.js - Node.js API Development for Beginners, you'll learn the core fundamentals of NodeJS so that you can start building API using NodeJS. You will learn Modern JavaScript, NodeJS event loop, Asynchronous programming, using node modules, npm modules and creating your own modules, creating server, connect to database and sending json responses.