Implement a Root-Level Request Logger Middleware

you can see it in any JavaScript challenge

if you don’t find it use a different method

this is a good one to learn

So like this?



I created a .js file, but this is what it show when I type node .js into the terminal:
Screenshot 2024-12-17 10.46.02 AM
Nothing happens. I did something wrong, but I don’t know what.

that looks like the myApp.js file? or is it a new one?

what did you add inside the new file? you should add only the few lines you need to use to test the console.log
also I don’t know if only .js is valid, it may need a proper name *.js, like test.js

It is a new .js file, and it has everything that myApp.js had.
I don’t think I need to add a proper name. If you look into the top left corner, it’ll show a file named .env, which I used to help complete the previous challenge.
Should I remove some things?

the file .env has a different function the a JavaScript file you execute

you should remove all of the code and add only the few lines you need to test the console.log

Okay, I’ll do that now and report what happened after.

All right, here’s what it shows in the terminal when I type node .js now:

GET /json ::ffff:127.0.0.1
GET /json - ::ffff:127.0.0.1

Everything matches except for the dash. Should I remove it?
EDIT: Never mind. I need to add my own. Here’s what it looks like now:

GET /json - ::ffff:127.0.0.1
GET /json - ::ffff:127.0.0.1

What should I do now? I checked the freeCodeCamp website to see if I passed, and it said I didn’t.

did you update the code in myApp.js? did you restart the server?

also read again the note right before the input to test your link

1 Like

IT WORKED THANK YOU THANK YOU THANK YOU THANK YOU