Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
519 B
1
Indexable
Never
const express = require("express");
const app = express();
const PORT = 3000;
let alumnos = require('./alumnos.json').alumnos;


app.use(express.json())

app.get('./alumnos/:id', (req, res) => {
    const{id} = req.params
    let alumno = alumnos.find(elemento => elemento.id == id)
    if(!alumno) {
        return res.status(404).json({msg:'Alumno encontrado'})
    } 
    res.status(200).json({msg: "Alumno no encontrado"})
    
})

app.listen(PORT, () => {
    console.log("escuchando!!!");
})