File tree Expand file tree Collapse file tree 1 file changed +20
-24
lines changed
Expand file tree Collapse file tree 1 file changed +20
-24
lines changed Original file line number Diff line number Diff line change @@ -197,29 +197,29 @@ And in your component make an API call to "/api/trending" route and render the r
197197``` jsx
198198import { useEffect , useState } from " react" ;
199199
200- export const fetchTopTrending = () => {
200+ const TopTrending = () => {
201201 const [trendingReports , setTrendingReports ] = useState ([]);
202202 useEffect (() => {
203- getTopTrendingReports ().then ((reports ) => {
204- setTrendingReports (reports );
203+ getTopTrendingReports ().then ((nodes ) => {
204+ setTrendingReports (nodes );
205205 });
206206 }, []);
207207
208208 return (
209- < ul>
210- {trendingReports .map ((node ) => {
211- return (
212- < li key= {node .path }>
213- < small className= " title" >
214- < Link className= " text-link" to= {` ${ node .path } ` }>
215- { node .path }
216- < / Link>
217- < / small>
218- < / li>
219- );
220- })}
221- < / ul>
222- )
209+ < ul>
210+ {trendingReports .map ((report ) => {
211+ return (
212+ < li key= {report .path }>
213+ < small className= " title" >
214+ < Link className= " text-link" to= {` ${ report .path } ` }>
215+ { report .path }
216+ < / Link>
217+ < / small>
218+ < / li>
219+ );
220+ })}
221+ < / ul>
222+ );
223223};
224224
225225async function getTopTrendingReports () {
@@ -228,15 +228,11 @@ async function getTopTrendingReports() {
228228 return [];
229229 }
230230 const reportNode = await response .json ();
231- let reports = [];
232- for (const node of reportNode .nodes ) {
233- reports .push (node);
234- }
235- return reports;
231+ return reportNode .nodes ;
236232}
237- ```
238-
239233
234+ export default TopTrending ;
235+ ```
240236
241237## Changelogs
242238See: https://github.com/7sferry/gatsby-plugin-google-analytics-data-reporting-api/releases
You can’t perform that action at this time.
0 commit comments