Test json parse MoreInfo - Fase 3

pull/1/head
Jéluchu 5 years ago
parent b0c0c61ff3
commit 001e15f446

@ -154,13 +154,14 @@ const getNews = async () =>{
const body = JSON.parse(JSON.stringify(rss, null, 3)).items const body = JSON.parse(JSON.stringify(rss, null, 3)).items
body.map(doc =>{ body.map(doc =>{
console.log(doc)
promises.push({ promises.push({
title: doc.title, title: doc.title,
url: doc.link, url: doc.link,
author: 'Ramen para dos', author: 'Ramen para dos',
content: doc.content content: doc.content
}); });
}); });
}); });

@ -171,11 +171,24 @@ router.get('/moreInfo/:title' , (req, res) =>{
let title = req.params.title; let title = req.params.title;
api.getMoreInfo(title) api.getMoreInfo(title)
.then(info =>{ .then(body =>{
console.log(info)
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) { if (info.length > 0) {
res.status(200).json({ res.status(200).json({
info: info info
}); });
} else { res.status(400) } } else { res.status(400) }
}).catch((err) =>{ }).catch((err) =>{

Loading…
Cancel
Save