Add /search route
This commit is contained in:
parent
9a97909e74
commit
d6925adcac
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue