Accessing API From Browser
The Query String
app.get('/api', (req, res) => {
console.log(req.query)
})
// If you go to localhost:3000/api?type=games...
// req.query returns { type: 'games' }if (!req.query.type) {
res.send({
error: 'You must provide a type query'
})
} else {
res.send(data)
}Last updated