Basic Node and Express - Use the .env File

Tell us what’s happening:

I keep seeing this error and I’m not sure what to do.

[Error: <!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<pre>Cannot GET /_api/use-env-vars</pre>

Your Code So Far

const express = require('express');
const cors = require('cors');
const app = express();



app.get('/json', (req, res, next) => {
  var response = "Hello json";
  if (process.env.MESSAGE_STYLE === "uppercase") {
    response = "Hello json".toUpperCase();
  } else {
    response = "Hello json";
  res.json({ message: response })


app.listen(3100, () => { // Make your API live
  console.log('Express server initialized');

Your project link(s)

solution: boilerplate-npm - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/118.0.2088.76

Challenge Information:

Basic Node and Express - Use the .env File

You are using the wrong repl for this challenge.
You should be using the boilerplate-express repl for all of these challenges (as linked in the challenge description in the first step).

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.