Anonymous Message Board

For some reason this test is failing and I can’t figure out how, using the console log it does show me there is an object that exists:

You can send a PUT request to
/api/threads/{board} and pass along the thread_id . Returned will be the string reported . The reported value of the thread_id will be changed to true .

code snippet:

    .put(async function (req, res) {
      const { report_id } = req.body;
      console.time("[PUT] - /api/threads/:board");
      const thread = getThreadById(report_id);
      console.timeEnd("[PUT] - /api/threads/:board");
      console.log("thread:", thread);
      if (!thread) return res.send("Not found");
      thread.reported = true;
      thread.bumped_on = getCurrentDate();
      res.send("reported");
    })

Post a link to this so it can be checked.

like a github link or a link to the challenge?

A link to your code, so GitHub, or Replit, Glitch, Gitpod.

I only looked at the api-with-mongodb.js version.

You are using the wrong id in the PUT route. If you look at the request/response in the network tab of the browser dev tools when you submit, the id you need to use should be easy to spot (it is the one in the payload for both PUT requests)

Also, the method for the delete is findOneAndDelete not findOneAndRemove

I’m not sure if I’m doing something wrong but if I need to use a specific id wouldn’t that be submitted on itself during the FCC tests? unless I’m misunderstanding what you said.

The id is part of the payload for the PUT request. You can inspect it using the browser dev tools.

im trying to see the id from my mongo DB to test the PUT request but i just found out that the database is empty with no query results

I assume you made the necessary changes required to switch to the DB version of the code?


Just to be clear, I’m not talking about the value of the id, I’m talking about the property name.

In your PUT route you have this

const { report_id } = req.body;

Just submit your code and look at the request/response. Or log out req.body in the PUT route.


As an aside, your gitignore file should be named .gitignore not gitignore.txt

regarding .gitignore it is formatted correctly in my gitpod workplace idk when i downloaded it and uploaded it to github it changed to a txt file instead so no worries about that.

I am pretty switched I switched to the DB version of my code since I added in my server.js to require the db.js file and it does log out that it connected to my database in the terminal when I start the code.

also I logged out req.body and it looks fine to me, it tells me the report_id in quotes

The req.body in the PUT route for /api/threads/:board should show you something else.

Compare that to the payload when you submit as well.

okay so I’m logging out req.body in api.js and that’s what the output in the terminal when I send a PUT request, basically just the board name and thread_id, i feel like im doing something wrong or there’s something missing im not catching on

So maybe try using thread_id instead?

Also, it is in the requirements.

You can send a PUT request to /api/threads/{board} and pass along the thread_id . Returned will be the string reported . The reported value of the thread_id will be changed to true .


Also, like I said. I only have and will test your DB version. So if there are any discrepancies between the two, I won’t know it.

i managed to fix it somehow, i just made sure that i changed report_id to thread_id in the functional test file and that made it work so yay?