docs icon indicating copy to clipboard operation
docs copied to clipboard

ethPriceInUSD variable assignment update (fixed error + added improvement)

Open markodayan opened this issue 3 years ago • 1 comments

The data response structure of the ETH_PRICE_QUERY GraphQL query has changed slightly and so this code would originally throw an error when trying to run this React app.

I looked at the response to the query and updated how the ethPriceInUSD is assigned (and ensure that it is done correctly). Running the React app in dev environment now works with no problem (change is on Line 234)

Previous assignment: const ethPriceInUSD = ethPriceData && ethPriceData.bundles[0].ethPrice; New assignment const ethPriceInUSD = ethPriceData && ethPriceData.bundle.ethPrice;

Also just added another div which shows the ETH rate (in USD) returned from the query (change is on Line 238)

      <div>
        ETH Price:{" "}
        {
          ethLoading
            ? "Loading token data..."
            : "$" +
            (parseFloat(ethPriceInUSD)).toFixed(2)
        }
      </div>

markodayan avatar Aug 21 '21 22:08 markodayan

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/uniswap/uniswap-docs/FxUsRhWgQYbim6xaHqwnRAJXPtGL
✅ Preview: https://uniswap-docs-git-fork-markodayan-v2-api-doc-fix-uniswap.vercel.app

vercel[bot] avatar Aug 21 '21 22:08 vercel[bot]