diff --git a/src/server/app.ts b/src/server/app.ts index be09eed..af46372 100644 --- a/src/server/app.ts +++ b/src/server/app.ts @@ -1,6 +1,6 @@ import express from "express"; -import scraper from "../scaper"; +import * as scraper from "../scraper"; const app = express(); const PORT = 8080; @@ -10,12 +10,8 @@ app.listen(PORT, () => { }); app.get("/", async (req, res) => { - // res.send(`Defintion for '${req.query.term}!'`); - const term = req.query.term; - console.log(term); - if (term == undefined) { res .status(400) @@ -27,13 +23,11 @@ app.get("/", async (req, res) => { } try { - const data = await scraper( - `https://www.urbandictionary.com/define.php?term=${term}` - ); + const defintions = await scraper.getDefinitions(term.toString()); - res.send(data); + res.json(defintions); } catch (e) { - res.status(500); + res.sendStatus(500); console.error(e); } });