Zuko
1
I am using replit so I have to use the Secrets tool in order to do this but what I am doing isn’t working. Need help
let express = require('express');
let app = express();
app.get("/", (req, res) => {
res.sendFile(absolutePath = __dirname + '/views/index.html');
});
app.use("/public",express.static(__dirname + '/public'));
app.get("/json", (req, res) => {
res.json({
"message": "Hello json"
});
});
const mySecret = process.env['MESSAGE_STYLE']
module.exports = app;
icxc
2
What course are you busy with? Be more precise, give more information.
Zuko
3
You must have not seen the link to the problem that I included
icxc
4
I didn’ see, sorry! I will take a look.
Is about:
The response object should either be {"message": "Hello json"}
or {"message": "HELLO JSON"}
, depending on the MESSAGE_STYLE
value.
Your json response is not conditional on the value of MESSAGE_STYLE
. You need to write a conditional statement which accounts for this.
Zuko
6
I changed it but it’s still not working
let express = require('express');
let app = express();
app.get("/", (req, res) => {
res.sendFile(absolutePath = __dirname + '/views/index.html');
});
app.use("/public",express.static(__dirname + '/public'));
app.get("/json", (req, res) => {
const mySecret = process.env['MESSAGE_STYLE'];
if (mySecret === 'uppercase') {
res.json({"message": "Hello json"});
} else {
res.json({"message": "HELLO JSON"});
}
});
module.exports = app;
Nevermind @igorgetmeabrain . Thank you! was a little mistake on my end. Fixed it:
app.get("/json", (req, res) => {
const mySecret = process.env['MESSAGE_STYLE'];
if (mySecret === 'uppercase') {
res.json({"message": "HELLO JSON"});
} else {
res.json({"message": "Hello json"});
}
});
icxc
7
You have to add this before app.get:
with :
hello what is the corrected one am having exact problem
icxc
9
Specifically, what’s the problem? Please provide some more information!