Navigating nested objects in JSON from an API: A guide to accessing hidden data

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...,....

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing JavaScript as an alternative to PHP in this specific scenario

Hey everyone, I'm looking to pass data from PHP to JavaScript. Below is my PHP code that I need to adapt for use in JavaScript: $result = dbMySql::Exec('SELECT Latitude,Longitude FROM data'); while ($row = mysqli_fetch_assoc($result)) $ ...

Exploring multiple arrays with nested loops using the JOLT library

Within my input data, there is a list of individuals. Each individual has multiple addresses and roles on the contract. For example : Individual #001 has : two addresses - secondary residence and tax address ; two roles - co-subscriber and insured Indi ...

What is the process of enabling scrolling on the main panel once scrolling on the sidebar has concluded?

How can I achieve a scrolling behavior similar to the one demonstrated here? When scrolling through the sidebar, I want it to continue scrolling until it reaches the end. After that, any further scrolling on the sidebar should scroll the main panel inste ...

ng-if directive does not show data in AngularJS

I have a dynamic collection of images and videos that I want to display one at a time. Specifically, when I click on an image ID, I want it to show the corresponding image, and when I click on a video ID, I want it to show the relevant video. Below is the ...

Customize Text Area's Font Based on Selected Option in Dropdown List

I'm currently working on an HTML file that includes a dropdown list and a text area. Here's the code snippet: <select id='ddlViewBy' name='ddlViewBy' onchange='applyfonttotextarea()'> <option value = ' ...

The markers on Google Maps are currently displaying in the wrong position, despite the latitude and longitude being correct

Utilizing the Google Maps API, I have implemented a system to dynamically add map markers tracking 2 of our company's vehicles. The website is developed in asp.net c# mvc with bootstrap 4.3.1. An ajax request retrieves the latest marker location from ...

Troubles with submitting jQuery validation plugin via AJAX

Whenever I try to use the jQuery validation plugin for validating a form within a Bootstrap modal, the validation does not work and the form cannot be submitted. This is the code for the Bootstrap modal form: <div class="modal fade" id="form-content" ...

Error: The API_URL_KEY variable has not been declared

hardhat.config.js require("@nomicfoundation/hardhat-toolbox"); /** @type import('hardhat/config').HardhatUserConfig */ module.exports = { solidity: "0.8.18", }; /* @type import('hardhat/config').HardhatUserConfig* ...

How come the use of a timeout causes the this variable to seemingly lose its reference?

What is the reason why this: myelements.mouseenter(function() { clearTimeout(globaltimeoutvar); globaltimeoutvar = setTimeout(function() { var index = myelements.index(this); console.log(index); // -1 }, 150); }); Returns -1, while this: m ...

Combining Multiple Arrays into a Single Array

Is there a way to combine this merge operation that creates one array using forEach into a single array at the end? affProd.pipe(mergeMap( event1 => { return fireProd.pipe( map(event2 => { const fi ...

Encountering a TypeError while trying to run Pythonshell on my Mac device

When I run a python script in node.js using python shell, it works perfectly on my Windows system. However, I encounter an error when trying to run the same thing on my Macbook: Error: TypeError: can't multiply sequence by non-int of type 'float ...

Utilizing a combination of MVC, jQuery, and Ajax to ensure that JavaScript is fully loaded before proceeding

Utilizing ASP.NET MVC and jQuery, I am loading a PartialView via Ajax which has its own accompanying JavaScript file. Upon successful retrieval of the html content, it is inserted into the DOM. However, there can be a delay between the insertion and the ex ...

What is the reason for XMLHttpRequest.status being equal to 0 in all browsers except for Internet Explorer?

I am encountering a frustrating issue... After developing a standalone RESTful.NET webservice using C#, I noticed that when I make a XMLHttpRequest to fetch JSON data, all browsers, except for IE, fail to retrieve the data. The problem lies in the status ...

What are some effective ways to identify all Typescript and ESLint errors across the entire NextJS project, rather than just the currently opened files

In my current NextJS project, I am searching for a way to display errors and warnings across the entire project, rather than just within the opened files. How can I achieve this? ...

Tips for verifying elements using the Loop technique in a JSON array

I am new to JavaScript and I have been trying to run the following code with an expected result like this: [["00:04:12","05:54:46"],["06:06:42","12:45:22"],["12:51:11","15:56:11"]] However, my script is not working as expected. Can someone please help ...

When comparing org.json.simple.JSONObject and org.json.JSONObject, the issue of JSONException not being able to be resolved as a

Could someone clarify the distinctions between org.json.simple.JSONObject and org.json.JSONObject? Also, I am encountering an issue with a code that uses org.json.JSONObject and org.json.JSONException. While editing the code in Eclipse (JUNO), it recogniz ...

Show or hide a div through two variables that toggle between different states

It's possible that I'm not fully awake, so missing the obvious is a possibility. However, I have 2 variables that determine whether a div has a specific class or not. The class functions more like a toggle; so the following conditions should tri ...

Struggling to understand the intricacies of MobX in conjunction with Next-Auth? Let

Below are the essential dependencies along with their versions from my package.json file: "mobx": "^6.5.0", "mobx-react": "^7.3.0", "next": "12.1.6", "next-auth": "4.2.1", &qu ...

Are the functionalities of twilio-common.js on github equivalent to those of twilio-client.js on their CDN?

Currently, I am integrating the Twilio SDK client from the twilio CDN using this link: //media.twiliocdn.com/sdk/js/client/v1.4/twilio.min.js However, I am interested in importing the package via npm due to some restrictions. The only option I see availa ...

Integrating content from a separate PHP page into the main index PHP page

I can't seem to get the #container1 div on my index.php page to load with the content from another #container2 div on page1.php. It's frustrating because I've checked my file hierarchy and everything seems correct. This is how my files are ...