Add /search route

This commit is contained in:
Francesco Esposito 2019-08-22 17:43:00 +02:00
parent 9a97909e74
commit d6925adcac
1 changed files with 7 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import express from 'express';
import { getCurrentWeatherById, getForecastWeatherById } from './apiOWM';
import { getCurrentWeatherById, getForecastWeatherById, getCityIdByName } from './api';
const router = express.Router();
@ -33,4 +33,10 @@ router.get('/forecast', (req, res) => {
});
router.get('/search', (req, res) => {
getCityIdByName(req.query.city)
.then((obj) => res.json(obj))
.catch((err) => res.status(500).send(err));
});
export default router;