Back End Development and APIs Projects - Request Header Parser Microservice

Tell us what’s happening:

I’ve coded a solution for the " Request Header Parser Microservice" in the API course, but for whatever reason it fails all of the tests.

I’ve tried different servers hosted at gitpod and replit and neither pass the tests. The console shows output during tests so something is happening. Moreover, when I look at other people’s solutions, they’re very similar and yet they seem to work?

githubLink: freeCodeCamp-Request-Header-Parser-Microservice/server.js at master · StevanFreeborn/freeCodeCamp-Request-Header-Parser-Microservice · GitHub

###Your project link(s)

githubLink: GitHub - raulg-cpp/header-parser-backend: Header parser challenge from FreeCodeCamp's backend challenge

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

I believe the problem is that Express applies middleware functions in the order that you have coded them. Since your app.get( "/api/whoami",... is at the top of the file, the middleware functions below aren’t running on them, and they are necessary to reach the ‘whomai’ route correctly.

1 Like

I just tried this and it work! Placed all custom code bellow the boilerplate. Thank you!!

1 Like