React.JS website not displaying on netlify

Hi @Rokinos

There is a succession of errors which I believe begins with the call to Unsplash which looks like

https://api.unsplash.com/photos/?client_id=undefined&page=1

which returns

Failed to load resource: the server responded with a status of 401 ()

with the error message

“OAuth error: The access token is invalid”

because the

process.env.REACT_APP_API_KEY

is returning undefined rather than a value. The TypeError as mentioned by @talves appears to stem from this API call as your script is trying to iterate over the returned object but no object is returned.

Have you set this environment variable in the Netlify UI?

Also note that if this key is a secret key, don’t use it inside a React app in this fashion as it is viewable to anyone. If you need to keep this key secret, move the API call to a serverless function instead.

1 Like