Having an issue with attaching an API key from my .env file. The key works if its placed in the component. However if I import it from the .env file it doesnt work. Getting a 401 (Unauthorized). Used the Create React App. Tried many different ways to try to make it work (add const, add REACT_APP before the var..).
The .env file...
REACT_APP_OPEN_WEATHER_API_KEY=`123456789123456789`;
The .jsx file...
import React from "react";
import REACT_APP_OPEN_WEATHER_API_KEY from '../.env';
const REACT_APP_API_ADDRESS = REACT_APP_OPEN_WEATHER_API_KEY;
class WeatherInfo extends React.Component {
constructor() {
super();
this.state = {
items: [],
isLoaded: false,
}
}
componentDidMount() {
fetch(`https://api.openweathermap.org/data/2.5/forecast?q=Austin,USA&appid=${REACT_APP_API_ADDRESS}&units=imperial`)
