From 30862b323f179a6277abad0033e3c8fee4b0d6c7 Mon Sep 17 00:00:00 2001 From: Ferry Suhandri Date: Tue, 11 Jun 2024 17:51:43 +0700 Subject: [PATCH] Update README.md --- README.md | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d27f19f..d7d4b3b 100644 --- a/README.md +++ b/README.md @@ -197,29 +197,29 @@ And in your component make an API call to "/api/trending" route and render the r ```jsx import { useEffect, useState } from "react"; -export const fetchTopTrending = () => { +const TopTrending = () => { const [trendingReports, setTrendingReports] = useState([]); useEffect(() => { - getTopTrendingReports().then((reports) => { - setTrendingReports(reports); + getTopTrendingReports().then((nodes) => { + setTrendingReports(nodes); }); }, []); return ( - - ) + + ); }; async function getTopTrendingReports() { @@ -228,15 +228,11 @@ async function getTopTrendingReports() { return []; } const reportNode = await response.json(); - let reports = []; - for (const node of reportNode.nodes) { - reports.push(node); - } - return reports; + return reportNode.nodes; } -``` - +export default TopTrending; +``` ## Changelogs See: https://github.com/7sferry/gatsby-plugin-google-analytics-data-reporting-api/releases