apuntes:backend_frontend
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| apuntes:backend_frontend [2026/10/28 22:51] – [CRUD Completo Backend] Santiago Faci | apuntes:backend_frontend [2026/10/28 22:52] (current) – [Backend: API] Santiago Faci | ||
|---|---|---|---|
| Line 356: | Line 356: | ||
| . . . | . . . | ||
| if (cities[name] === undefined) { | if (cities[name] === undefined) { | ||
| - | res.status(404).json({ | + | |
| error: 'No se ha podido encontrar la ciudad' | error: 'No se ha podido encontrar la ciudad' | ||
| }); | }); | ||
| Line 373: | Line 373: | ||
| const population = req.body.population; | const population = req.body.population; | ||
| if (typeof population !== ' | if (typeof population !== ' | ||
| - | res.status(400).json({ | + | |
| error: ' | error: ' | ||
| }); | }); | ||
| Line 419: | Line 419: | ||
| app.get('/ | app.get('/ | ||
| - | res.json(cities); | + | |
| }); | }); | ||
| app.get('/ | app.get('/ | ||
| const city = req.params.city; | const city = req.params.city; | ||
| - | res.json(cities[city]); | + | |
| }); | }); | ||
| Line 437: | Line 437: | ||
| }; | }; | ||
| - | res.status(201).end(); | + | |
| }); | }); | ||
| Line 620: | Line 620: | ||
| const data = await findAllCities(); | const data = await findAllCities(); | ||
| - | res.status(200).json(data); | + | |
| }); | }); | ||
| Line 627: | Line 627: | ||
| const data = await findCity(req.params.city); | const data = await findCity(req.params.city); | ||
| - | res.status(200).json(data); | + | |
| }); | }); | ||
| Line 634: | Line 634: | ||
| await registerCity(req.body.name, | await registerCity(req.body.name, | ||
| - | res.status(201).json({}); | + | |
| }); | }); | ||
| Line 641: | Line 641: | ||
| await modifyCity(req.params.city, | await modifyCity(req.params.city, | ||
| - | res.status(204).json({}); | + | |
| }); | }); | ||
| Line 648: | Line 648: | ||
| await removeCity(req.params.city); | await removeCity(req.params.city); | ||
| - | res.status(204).json({}) | + | |
| }); | }); | ||
apuntes/backend_frontend.1793227881.txt.gz · Last modified: by Santiago Faci
