diff --git a/node-entry.js b/node-entry.js index b65686a..09588f0 100644 --- a/node-entry.js +++ b/node-entry.js @@ -67,7 +67,7 @@ low(new FileAsync(__dirname + '/db.json')) // production if (row.value()) { let tmpA = videos.filter(x => x.id !== req.query.id).map(x => { return { - "videoId": x.id, + "videoID": x.id, "timesWatched": x.timesWatched, "prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason, "lastSelected": x.lastWatched @@ -83,7 +83,7 @@ low(new FileAsync(__dirname + '/db.json')) // production else { let tmpA = videos.map(x => { return { - "videoId": x.id, + "videoID": x.id, "timesWatched": x.timesWatched, "prevalentReason": x.reason.sort((a, b) => a.timesWatched - b.timesWatched).reverse()[0].reason, "lastSelected": x.lastWatched diff --git a/src/reccomenders/popGlobaleAssoluta.js b/src/reccomenders/popGlobaleAssoluta.js index 27b6dc8..a8e2fd0 100644 --- a/src/reccomenders/popGlobaleAssoluta.js +++ b/src/reccomenders/popGlobaleAssoluta.js @@ -13,32 +13,21 @@ class popGlobaleAssoluta extends React.Component { }; componentDidMount() { - // listSiti.map( - // sito => - // axios.get(`http://site${sito}.tw.cs.unibo.it/globpop`, { - // 'params': { - // 'id': this.props.match.params.id - // } - // }) - // ) - - // let listSiti = ['1828', '1829', '1838', '1839', '1846', '1822', '1847', '1831', '1827', '1848', '1824', '1830', '1836', '1850', '1849', '1851', '1861', '1823', '1863', '1834', '1904', '1906', '1901', '1862', '1859']; - let listSiti = ['1828', '1838', '1839', '1846', '1831', '1827', '1849', '1823', '1863', '1834', '1901', '1859']; - let axiosReq = []; - for (let i = 0; i < listSiti.length; i++) { - console.log(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`) - axiosReq.push(axios.get(`http://site${listSiti[i]}.tw.cs.unibo.it/globpop`, { - 'params': { - 'id': this.props.match.params.id - } - })) - } - Promise.all(axiosReq) - .then(axios.spread((...res) => { - console.log(res.map(x => x.data)) - }) + let listSiti = ['1828', '1838', '1839']; + Promise.all( + listSiti.map( + el => fetch(`http://site${el}.tw.cs.unibo.it/globpop?id=${this.props.match.params.id}`) + .then(res => + res.json() + ) ) + ).then(res => { + /* do something with res here... */ + console.log(res) + let tmp = res.map(x => x.recommended); + let tmp2 = tmp.map(el => el.map(el1 => el1.videoID || el1.videoId) ) + }); } // METODI