I am currently utilizing the cryptocomare API to retrieve data on various crypto coins within a Nextjs App. My approach involves redirecting users to the coin details page when they click on a specific symbol. I then attempt to extract this clicked symbol using getServerSideProps as shown below, dynamically incorporating it into the API call and sending it to the server.
`
export const getServerSideProps = async (context) => {
const res = await fetch(
`https://min-api.cryptocompare.com/data/pricemultifull?tsyms=USD&fsyms=${context.params.symbol}`
);
const icon = await res.json();
return {
props: {
icon,
},
};
};
` The API call returns a JSON object with nested objects that are several levels deep. At the top level, the structure appears as follows: API call response
Within my code, my goal is to access the data Object -> RAW -> (whatever the user clicked on). However, since the queried Symbol or coin is dynamic (meaning I cannot predict what will be clicked), I face uncertainty regarding what to query. As a solution, I attempted to access the data using object.RAW[0]
In theory, this should provide me with any object contained within the object.RAW
. Yet, it instead returns undefined
Could someone kindly offer guidance on how I can retrieve the data inside object.RAW
without prior knowledge of its contents?
Thank you!
I have explored utilizing object.RAW[0]
to access the data...,....