Skip to content

Instantly share code, notes, and snippets.

@ProfAndreaPollini
Created January 18, 2021 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ProfAndreaPollini/d43ad730774f5c9e95c445c55b1e477d to your computer and use it in GitHub Desktop.
Save ProfAndreaPollini/d43ad730774f5c9e95c445c55b1e477d to your computer and use it in GitHub Desktop.
materiale lezione 18 1 2021
const express = require("express")
const app = express()
// elenco di tutti i dischi: GET /vinyls
app.get("/vinyls", (req, res) => {
res.send([
{
titolo: "disco 1",
autore: 1
},
{
titolo: "dsico 2",
autore: 2
}
])
})
// elenco degli autori: GET /authors
app.get("/authors", (req, res) => {
res.send([
{
nome: "pinco pallo",
id: 1
},
{
nome: "test",
id: 2
}
])
})
// elenco dei generi: GET /genres
// recuperare informazioni su un disco GET /vinyls/234
app.get("/vinyls/:id", (req, res) => {
const { id } = req.params
// TODO: recupero dettagli vinile richiesto
// ritorno valori al client
res.send({
titolo: "disco 1",
autore: 1
})
})
// recuperare tutti i dischi di un autore GET /authors/2/vinyls
// recuperare i dischi di un genere GET /genres/1/vinyls
app.listen(9999, () => {
console.log("it works!")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment