Conversation
| * **Your Answer:** | ||
|
|
||
| --- | ||
| * When a get request is running. It appears to be called before all other functions. Top down. |
| * **Question:** What type of thing is `app` and what is its purpose? | ||
|
|
||
| * **Your Answer:** | ||
| * app is our application referenced in the app.js and shown in browser via index.js. |
There was a problem hiding this comment.
our instance of the server. also a function / event emitter
| * **Question:** What type of thing is `req` and what does it represent in the callback? | ||
|
|
||
| * **Your Answer:** | ||
| * It is looking for a request. |
| * **Question:** What type of thing is `next` and what does it represent in the callback? | ||
|
|
||
| * **Your Answer:** | ||
| * If after running the first get() move to the next get() function. |
There was a problem hiding this comment.
Continues to forward the request to the next matching route.
| * **Your Answer:** | ||
|
|
||
| --- | ||
| * req.params is the request parameter :name. If you change thet get request parameter to :username you have to change the the response message to reflect the name of the parameter to ${req.params.username}. |
| * **Your Answer:** | ||
|
|
||
| --- | ||
| * The middleware will run before a route. |
There was a problem hiding this comment.
Sometimes, depends on where it is defined in the route chain.
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.
| * **Your Answer:** | ||
|
|
||
| --- | ||
| * If morgan is signed in he or she will have dev environment variable. The body-parser appears to set the environment variable to json(). Meaning it's parsing all data to json. |
There was a problem hiding this comment.
Morgan provides logs which are not very useful outside of development.
without body-parser we would lose access to req.body
| * **Question:** Try creating a new vegetable. Then, try restarting your server. What happens to the data you posted and why? | ||
|
|
||
| * **Your Answer:** | ||
| I was having issues with getting anything to post to state. But considering that it was a state if you refresh the server I would assume state would be saved. |
There was a problem hiding this comment.
Since we never saved the data to a file or database it exists only as a javascript object which is lost when the server restarts.
|
|
||
| * **Your Answer:** | ||
|
|
||
| * These are the formating standards for writing code so developers across the galaxy will understand and be able to read your code easier and faster. |
No description provided.