Tell us what’s happening:
if (process.env.MESSAGE_STYLE === 'uppercase') {
res.join({'message': upperCase.toUpperCase()})
} else {
res.join({'message': upperCase});
}
});
I’m stuck, I’ve added the dotenv package to the top of my app.js file to insure performance. Could I be missing something minor?
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Challenge Information:
Basic Node and Express - Use the .env File
The instructions don’t talk about this?
Where is the variable upperCase
defined?
It doesn’t, it’s from the note recommended I know that the package is already installed pre set-up. The upperCase is var is located above the app.get function. I’ve put it inside the function above the if statement, but I still have the outcome of 2 “*” in the terminal.
It would help if you show all of your code.
app.get('/json', (req, res) => {
res.json({
'message': 'Hello json'
});
let upperCase = 'Hello json';
if (process.env.MESSAGE_STYLE === 'uppercase') {
res.join({'message': upperCase.toUpperCase()})
} else {
res.join({'message': upperCase});
}
});
This is what my code looks like.
If that is all of you code’s then you need to put back all the stuff you deleted from the code.
Please actually post your code instead of a picture
let express = require('express');
const req = require('express/lib/request');
let app = express();
let pass = require('dotenv').config();
app.get('/', (req, res) => {
res.sendFile(absolutePath = __dirname + '/views/index.html');
})
app.use('/public', express.static(absolutePath = __dirname + '/public')
)
app.get('/json', (req, res) => {
res.json({
'message': 'Hello json'
});
let upperCase = 'Hello json';
if (process.env.MESSAGE_STYLE === 'uppercase') {
res.join({'message': upperCase.toUpperCase()})
} else {
res.join({'message': upperCase});
}
});
Why are you doing both a res.json and a res.join?
Was thinking of a different way to do it.
let express = require('express');
const req = require('express/lib/request');
let app = express();
let pass = require('dotenv').config();
app.get('/', (req, res) => {
res.sendFile(absolutePath = __dirname + '/views/index.html');
})
app.use('/public', express.static(absolutePath = __dirname + '/public')
)
app.get('/json', (req, res) => {
res.json({
'message': 'Hello json'
});
let upperCase = 'Hello json';
if (process.env.MESSAGE_STYLE === 'uppercase') {
upperCase = 'Hello json'.toUpperCase();
} else {
upperCase = 'Hello json';
}
});
I’ve tried it this way also.
I’m not sure that answers my question
ooh it’s a typo error, it’s meant to say json must have been too fast.
ILM
March 8, 2025, 9:34am
14
this is your response, as this is the res.json
, so it does give always the same, it doesn’t change based on MESSAGE_STYLE
what do you want to do with the code after that?