[SOLVED] I am getting axios error | zapper clone

import React from ‘react’

import axios from “axios”;

const NativeTokens = ({wallet,chain,nativeBalance,nativeValue,setNativeBalance,setNativeValue}) => {

const getNativeBalance = async () => {

    try {

      const response = await axios.get("http://localhost:8080/nativeBalance", {

        params: {

          address: wallet,

          chain: chain,

        },

      });

 

      console.log(response);    

      if (response.data.balance && response.data.usd) {

        setNativeBalance((Number(response.data.balance) / 1e18).toFixed(3));

        setNativeValue(((Number(response.data.balance) / 1e18) * Number(response.data.usd)).toFixed(2));

       

      }

    } catch (error) {

      console.error("Error occurred while fetching native balance:", error);

     

    }

  };

 

return (

    <>

    <h1>Fetch Tokens</h1>

    <p>

      <button onClick={getNativeBalance}>Fetch Balance</button>

      <br />

      <span>

        Native Balance: {nativeBalance}, (${nativeValue})

      </span>

    </p>

  </>

)

}

export default NativeTokens

do you see any error on your sever?

Hey i have solved my error in the video of zapper clone nativeBalance.usd = nativePrice.data.usdPrice; was given in the code but my error solved by using raw instead of data nativeBalance.usd = nativePrice.raw.usdPrice; Thanks for your reply :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.