I always this response when I try to validate my code: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE (Test timed out)
this is my code:
var express = require('express')
var app = express()
app.get('/json', function(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;
Your project link(s)
solution: boilerplate-express-1 - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.52
Challenge: Use the .env File
Link to the challenge:
Did you set the environment variable using the secret tab?
This endpoint https://boilerplate-express-1.gharsallihelmi.repl.co/json
should by default return the uppercase response if you set the environment variable correctly.
Yes, I did. And I tested it successfully when its value is ‘uppercase’ and when it’s not.
ilenia
April 13, 2022, 2:22pm
4
and what link are you submitting?
ilenia
April 13, 2022, 2:26pm
6
what value have you given to the env variable?
it just passed! that’s weird. All I changed was remove the “/” from the end of my submitted link. didnt know that could make a difference.
zch
April 13, 2022, 4:05pm
8
Thank you!After seeing your code I just realize my mistake is to use a var to be the value of message ,its ok to realized but cant pass the test.
1 Like
ilenia
April 13, 2022, 5:35pm
9
please create a topic showing the code you have written if you need help
1 Like
system
Closed
October 13, 2022, 5:35am
10
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.