Video 54: The Query String
This commit is contained in:
parent
6116711a55
commit
a34f5e05c3
|
@ -40,9 +40,29 @@ app.get('/help', (req, res) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/weather', (req, res) => {
|
app.get('/weather', (req, res) => {
|
||||||
|
if (!req.query.address) {
|
||||||
|
return res.send({
|
||||||
|
error: 'You must provide an address!'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
forecast: 'It is snowing. In September.',
|
forecast: 'It\'s pretty nice out. Not bad, really.',
|
||||||
location: 'Calgary'
|
location: 'Calgary',
|
||||||
|
address: req.query.address
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/products', (req, res) => {
|
||||||
|
if (!req.query.search) {
|
||||||
|
return res.send({
|
||||||
|
error: 'You must provide a search term'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(req.query.search)
|
||||||
|
res.send({
|
||||||
|
products: []
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue