hello can you help get rid off this annoying breaks \n\n\n\n\n that are showing receiving an express response.and organize the JSON response this the code :
onst request = require("request-promise");
const express = require('express')
const cheerio = require("cheerio");
const app = express()
const PORT = 8888;
app.get('/td', async (req, res) => {
const results = [];
try {
const result = await request.get("https://www.fctables.com/algeria/1-division/");
const $ = cheerio.load(result);
$("#table_stage_35295 > tbody > tr").each((index, element) => {
if (index === 0) return true;
const tds = $(element).find("td");
const rank = $(tds[0]).text();
const team = $(tds[1]).text();
const points = $(tds[3]).text();
const tableRow = { rank,
team,
points };
results.push({
rank,
team,
points
});
});
} catch (err) {
console.error(err);
}
res.json(results)
});
app.listen(PORT, () => console.log(`surver running on PORT ${PORT}`))
as you can see, that was the code and below you will find the json response:
[{"rank":"2","team":"\n CS Constantine\n \n ","points":"29"},{"rank":"3","team":"\n JS Saoura\n \n ","points":"23"},{"rank":"4","team":"\n ES Setif\n \n ","points":"22"},{"rank":"5","team":"\n MC Alger\n \n ","points":"22"},{"rank":"6","team":"\n USM Khenchela\n \n ","points":"20"},{"rank":"7","team":"\n USM Alger\n \n ","points":"19"},{"rank":"8","team":"\n RC Arbaa\n \n ","points":"18"},{"rank":"9","team":"\n US Biskra\n \n ","points":"17"},{"rank":"10","team":"\n NC Magra\n \n ","points":"17"},{"rank":"11","team":"\n ASO Chlef\n \n ","points":"17"},{"rank":"12","team":"\n MC El Bayadh\n \n ","points":"16"},{"rank":"13","team":"\n MC Oran\n \n ","points":"16"},{"rank":"14","team":"\n JS Kabylie\n \n ","points":"12"},{"rank":"15","team":"\n Paradou AC\n \n ","points":"12"},{"rank":"16","team":"\n Chelghoum\n \n ","points":"1"}]
**what i want is ** to remove these \n\n\n\n and organize the response to be like this:
"rank": "2"
"team": "CS Constantine"
"points": "29"
....etc
thanks