I’ve been reading up on this topic, but I’m still not sure if I’m understanding this correctly.
Does the following code permit me to console {'name': eric}?
// req.query -> after ?
// req.params -> Can be written within url
app.get('/api/:date?name=bob', (req,res) => {
console.log(req.query) // {name: bob}
})
I am aware I could easily test this on my own console, but it is not working for some reason.
As I understand :date means I would use req.params.date to access the value at date. What I’m caught up on is I’m going to have to immediately use req.query because of the question mark (?). So, if I want to access ‘bob’, would I have to write this?: