Skip to content

Q#10

Open
jaamp wants to merge 2 commits intopce-uw-jscript400:masterfrom
jaamp:master
Open

Q#10
jaamp wants to merge 2 commits intopce-uw-jscript400:masterfrom
jaamp:master

Conversation

@jaamp
Copy link

@jaamp jaamp commented Jul 9, 2019

No description provided.

* **Question:** What are query parameters? Try going to a couple of your favorite websites and paste an example of query parameters being used.

* **Your Answer:**
* **Your Answer:anything after ? you have a key value pair. for about course is the key and javascript is the value
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passes these additional parameters in the url after the route. Useful for filters etc.

* **Question:** Instead of a `GET` request, lets say we want to listen in for a `POST` request. What do you think you needs to change?

* **Your Answer:**
* **Your Answer: it is from the client telling the server to create, update or delete an object
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as code goes, we need to use
app.post

* **Question:** Right now all of our requests will return a "Status Code" of 200. Define what a status code is and research how you could change it.

* **Your Answer:**
* **Your Answer:satus code indicate the success or failure of a request or return status - 200 is success, there are several like not found, or unauthorized, they let the client know why or where a request failed or was successful or redirected. Add a.status method
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to change use res.status(CODE)...

* **Question:** The above can be described as middleware. Describe what middleware is in your own words and how it differs from building a route.

* **Your Answer:**
* **Your Answer: Middleware can be the gate that params go through that screen for access or redirect as needed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Middleware is the code/application/module that communicates between two systems, such as between servers and databases. The code above is different than a route because it is always run whenever the application gets to these lines.

* **Question:** Describe the purpose of both morgan and body-parser. Why do you think morgan is only being run when the application is run in development mode?

* **Your Answer:**
* **Your Answer:Morgan is a request logger, body-parser parses your request and converts it into a format from which you can easily extract relevant information that you may need
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

* **Question:** Try commenting out `body-parser` in your application. What happens and why?

* **Your Answer:**
* **Your Answer: I must have done somethign wrong, I did not see any changes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If commented out you should loose access to req.body and therefore cannot send a proper response.

* **Question:** Take a look at the last two `app.use()` methods at the end of the file. Describe how both work and what `err` is refers to.

* **Your Answer:**
* **Your Answer:The first sets a not found (404) message if the inputed request cannot be found, the second is the response to the request
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants