Https://boilerplate-express.codebrakerk.repl.co/

Tell us what’s happening:
Code is right but freecodecamp test is failed,
I have tried it in both repl.it and glitch
But the test is not completed.

Your code so far

var express = require('express');
var app = express();
console.log("hello world"); 
app.use(express.static(__dirname+"/public"));
app.get("/",function(req,res){
  res.sendFile(__dirname+"/views/index.html");
  
  
});

// a--> 11)  Mount the body-parser middleware  here


/** 1) Meet the node console. */


/** 2) A first working Express Server */


/** 3) Serve an HTML file */


/** 4) Serve static assets  */


/** 5) serve JSON on a specific route */

  /** 6) Use the .env file to configure the app */
 app.get('/json',function(req,res){
   let response="Hello Json".toUpperCase();
   if(process.env.MESSAGE_STYLE==="uppercase"){
     response="Hello Json".toUpperCase();
     
   }else{
     response="Hello Json";
   }
 res.json({
   "message":response
 });
 })
 
/** 7) Root-level Middleware - A logger */
//  place it before all the routes !


/** 8) Chaining middleware. A Time server */


/** 9)  Get input from client - Route parameters */


/** 10) Get input from client - Query parameters */
// /name?first=<firstname>&last=<lastname>

  
/** 11) Get ready for POST Requests - the `body-parser` */
// place it before all the routes !


/** 12) Get data form POST  */



// This would be part of the basic setup of an Express app
// but to allow FCC to run tests, the server is already active
/** app.listen(process.env.PORT || 3000 ); */

//---------- DO NOT EDIT BELOW THIS LINE --------------------

 module.exports = app;

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 7.1.2; Redmi 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Mobile Safari/537.36.

Challenge: Use the .env File

Link to the challenge:

Hey Suresh,

nice to meet you! :slightly_smiling_face:

I’ve edited your post for readability, because it was very hard to read.

You can use the “preformatted text” tool in the editor ( </> ) to add code.


It would be awesome to see your projects on replit or glitch,
so we can have a deeper look at it and test stuff.

1 Like

Thanks for your suggestion miku :slightly_smiling_face
Links for the project.
Repl.it

Glitch

Hello there,

Something to note:

  • The original text (from previous challenge) is:
    {"message": "Hello json"}

Hope this helps

1 Like

Thanks @Sky020
It worked :slight_smile: