Get Data from POST Requests and the entire Node.js course

I have had an unnecessarily hard time with this particular course i do not know why. Are you required to know backend or something else before taking this course? Because it hella seems so. Every challenge i click the get a hint button, which chips away my self esteem, and msot of the time, i dont even know what I’m doing.
No matter what i do i cannot get this to be approved or something and I’m getting honestly tired. I dont think I’ll continue the course, but if anyone has a solution to why my code is not working, i would love to know.
Thanks

var express = require(‘express’);
var app = express();
var bodyParser = require(“body-parser”);

var urlencodedParser = app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json);

app.post(’/name’, urlencodedParser, function(req, res) {
var string = req.body.first + " " + req.body.last;
res.json({ name: string });
});

here is my code, for those who care

Your project link(s)

solution: https://replit.com/@jemi-code/boilerplate-npm-1

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

Challenge: Get Data from POST Requests

Link to the challenge:

Welcome to the forum.

I have had an unnecessarily hard time with this particular course i do not know why.

Yeah, I think we can all relate. Coding is hard. And it gets harder the deeper you get into it. And I remember struggling on this section. But it does pay off in the long run.

Every challenge i click the get a hint button, which chips away my self esteem, and msot of the time, i dont even know what I’m doing.

Yeah, I know it is tough, but the less you do that the better. But I do understand the frustration.

And FCC is not meant to be comprehensive. You are expected to google things and try to figure things out. And that is something that a professional developer does all … the … time. I cannot stress that enough.

When I look at your code in the replit you provided, it does not contain the code that you posted here.

Please provide a replit that has the code you are trying.

When I go to the replit that you provided…

The first thing that I like to do is make sure the server is running and I can hit it. When I add a simple “ping” path to test the server by adding:

app.get('/ping', function(req, res) {
  res.json({ ping: 'pong' });
});

I can test that path by putting the server url with that path into my browser address bar:

https://boilerplate-npm-1.kevinsmith127.repl.co/ping

I get the response:

{"ping":"pong"}

Note: That is the path to my fork of your server - yours will be different.

That is how you test a simple GET path. Testing POST paths is a little more complicated. (I don’t know if there is an easy way in the browser or replit.) You can do that from the command line with curl.

From a terminal or the shell tab, I can use this to test that GET path:

curl -X GET https://boilerplate-npm-1.kevinsmith127.repl.co/ping

I find that awkward to use. Fortunately there is a great tool called postman that makes it really easy to test these. (There are others, too.)

If I want to set up a POST route, I would add this to the server…

app.post('/ping', function(req, res) {
  res.json({ ping: 'pong from post' });
});

… and restart.

I can’t test that from the browser (at least I don’t know how.) I can test it with curl with this:

curl -X POST https://boilerplate-npm-1.kevinsmith127.repl.co/ping

But I find it much easier to do it with postman.

See if you can get at least that far and then build on that to get the other requirements.

Another tool that is very helpful are the devtools. For example, if I go to the FCC test page for that challenge, and I open up the dev tools, I can look at the network tab and see exactly how FCC is trying to test the service.

Those ones in red are the tests. They are red because they failed to connect - the server is returning 404 because it cannot find those paths. You can click on those to get more information about what it being sent. Yes, it is a lot of info and it is confusing.

But again, see if this helps you get closer.

And remember - this is hard for everybody. That is a good thing - that is why it pays well - because it is hard. Trust me, unless someone has done a lot of http work before, this is confusing to everyone.

Does that help?