Req and Res in nodejs, problem in understanding arguments

3

I saw myself with the problem of understanding in depth what the res and req means in node js, but you have to understand the problem, I understand everything about what is res, and what is req and I know for which uses them, but a function for example, function soma (x, y) it receives the arguments x and y so that inside its body it does the sum process and then we can use the result, OK!

But in the case of the reqs, the req is as the name already says, a request, and res is the answer to that, so in my head it makes no sense to receive the request and the response function. / p>

The question that remains is, how is this processed on the machine?

For me the concept is, I arrive in a bakery and I want bread of salt, but first I have to ask if there is salt bread, but I already know that there is salt bread, so I ask the baker and at the same time I give the answer to him, and then I wait for him to answer something that I have already answered.

At least that's how it got understood, and I know it's wrong.

    
asked by anonymous 14.09.2018 / 05:23

1 answer

2

In this case, the expression function uses the HTTP protocol, which is based on req and res , so the req is an object containing information about the HTTP request of the event, header information, try to give a console.log(req) , ja res is basically the object that contains the server response.

    
14.09.2018 / 06:00