Welcome to the Linux Foundation Forum!

thoughts on lab-3.1 LFW212

Options

i am trying to solve lab3.1
this is the criteria of the lab
Using any Node.js core library and/or web framework, create an HTTP server that meets the following criteria:

  • Listens on localhost
  • Listens on port 3000
  • Responds to HTTP GET requests to / with data from the data function as exported from the data.js
  • Responds with a 404 to GET requests to any other route

i am using fastify to solve this lab and this my code for ('/') route

"use strict";
const data = require('../data');

module.exports = async (fastify, opts) => {
  fastify.get('/', async (req, reply) => {
    return await data();
  })
}

when i run node validate
i got this error

⛔️ http://localhost:3000 must respond with result calling data lib function

i added log inside the assertion
and this is the data was logged
content.toString() 3g7zncKOScl3uQ==
data u1THmSuKr7vXJg==
⛔️ http://localhost:3000 must respond with result calling data lib function

i think there is an error in the assertion.

Best Answer

  • juanmdpc
    juanmdpc Posts: 1
    Answer ✓
    Options

    The answer is right. I've got a similar issue, it happens when you execute the validation but this fails, so when you try again, this continues to fail because the port is being executed. So, could you try to kill the PID?
    Use these commands:
    lsof -i tcp:3000 / 3000 is the port you're using here
    kill -9 {the PID of that PORT}

Answers

Categories

Upcoming Training