Add comment for app.get() method usage#2102
Add comment for app.get() method usage#2102Melkzedk wants to merge 1 commit intoexpressjs:gh-pagesfrom
Conversation
Added comment to explain app.get() method.
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🚦 Lighthouse Results (Mobile & Desktop)
|
|
Thanks for the PR! IMO it could be helpful to have some comments in the hello world example, but I'm not sure if this particular comment is helpful. Maybe you could check similar frameworks (e.g fastify) to see how they handle their hello world example |
ShubhamOulkar
left a comment
There was a problem hiding this comment.
@Melkzedk, thank you for your efforts. But these changes can not improve documentation.
| const app = express() | ||
| const port = 3000 | ||
|
|
||
| //app.get() is a method used to define a route that responds to HTTP GET requests. |
There was a problem hiding this comment.
What do you think if we add something like this:
const express = require('express')
const app = express()
const port = 3000
// Define a route handler for GET requests to the root URL ('/')
// When someone visits http://localhost:3000/, this function runs
app.get('/', (req, res) => {
res.send('Hello World!') // Send back the response
})
// Start the server and listen for incoming requests on the specified port
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})cc: @efekrskl @ShubhamOulkar @expressjs/docs-wg
There was a problem hiding this comment.
Looking more in depth, the hello world page contains some extra details outside the example, which already cover these details. I would say we can close the PR.
There was a problem hiding this comment.
I agree, maybe it made sense to add some commentary directly in the code example, but I’m inclined to close the PR.
Added comment to explain app.get() method.