diff --git a/src/api/api.js b/src/api/api.js index 7121bb2..af255de 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -154,13 +154,14 @@ const getNews = async () =>{ const body = JSON.parse(JSON.stringify(rss, null, 3)).items body.map(doc =>{ - console.log(doc) + promises.push({ title: doc.title, url: doc.link, author: 'Ramen para dos', content: doc.content }); + }); }); diff --git a/src/api/routes/index.js b/src/api/routes/index.js index 5eea8e8..3e97c6a 100644 --- a/src/api/routes/index.js +++ b/src/api/routes/index.js @@ -171,11 +171,24 @@ router.get('/moreInfo/:title' , (req, res) =>{ let title = req.params.title; api.getMoreInfo(title) - .then(info =>{ - console.log(info) + .then(body =>{ + + const data = JSON.stringify(body); + const myEscapedJSONString = data + .replace(/\\n/g, "\\n") + .replace(/\\'/g, "\\'") + .replace(/\\"/g, '\\"') + .replace(/\\&/g, "\\&") + .replace(/\\r/g, "\\r") + .replace(/\\t/g, "\\t") + .replace(/\\b/g, "\\b") + .replace(/\\f/g, "\\f"); + + const info = JSON.parse(myEscapedJSONString) + if (info.length > 0) { res.status(200).json({ - info: info + info }); } else { res.status(400) } }).catch((err) =>{