JSON in nodejs doesn't give me all informations

node.js json get value
node js json parse
nodejs read json file
node js parse json array
how to fetch data from json in node js
node js json object
update json file using node js
node js write json to file

I try to get some data from API. In postman I get

{
    "data": {
        "platformInfo": {
           someInfos
        },
        "userInfo": {
            someInfos
        },
        "metadata": {},
        "segments": [
            {
                someInfos,
                "stats": {
                    "timePlayed": {
                        "rank": null,
                        "percentile": 77.0,
                        "displayName": "Time Played",
                        "displayCategory": "General",
                        "category": "general",
                        "metadata": {},
                        "value": 3404734,
                        "displayValue": "39d 09h 45m",
                        "displayType": "TimeSeconds"
                    },
                     other stats here

                }
            }
        ],
        "availableSegments": [],
        "expiryDate": "2019-12-15T17:19:18.9051055Z"
    }
}

but in node.js I've got

{
    "data": {
        "platformInfo": {
           someInfos
        },
        "userInfo": {
            someInfos
        },
        "metadata": {},
        "segments": [Object],
        "availableSegments": [],
        "expiryDate": "2019-12-15T17:19:18.9051055Z"
    }
}

How you can see diffirence is in "segments".

My get request from node.js:

        var request = require('request');
        var JsonFind = require('json-find');
        var url = 'https://public-api.tracker.gg/v2/csgo/standard/profile/steam/steamId';
        request.get({
          url: url,
          json: true,
          headers: {'TRN-API-KEY': 'Some api-key'}
        }, (err, res, data) => {
          if (err) {
            console.log('Error:', err);
            // error, reject
            reject(err);
          } else if (res.statusCode !== 200) {
            console.log('Status:', res.statusCode);
            reject(res.statusCode);
          } else {
            console.log(data.segments)
            }
          })

Where I use console.log(data.segments), I' ve got undefined object. I don't where problem is. Probably the problem is a big data in segments. Of course code works for co


the reason is that the default depth of accessing using console.log is 2 you have two ways to handle it

  1. console.log(JSON.stringify(x, null, 2)) where 2 is the number of spaces to use for indentation.

    2.require('util').inspect.defaultOptions.depth = null and this will remove any limit on depth

Reading and Writing JSON Files with Node.js, To read the JSON data from the file we can use the Node.js fs module. There are two Without the proper extension require doesn't treat the file as JSON file. JSON is one of the most common types of data you’ll work with in Node, and being able to read and write JSON files is very useful. You’ve learned how to use fs.readFileand fs.writeFileto


What did you console.log to get that response from nodejs? I would suggest using JSON.stringify() to check what are the contents of the result. This will expand the segments object and show its full content just like postman.

Most likely this is an issue understanding the structure of the response object recieved. I would suggest doing a console.log of data as well.

How to Use JSON files in Node.js, Node.js has emerged as a leading platform for creating fully scalable applications within least amount of time. Additionally, the platform� package.json is a JSON configuration file of a nodejs project which contains metadata of an application + dependencies etc. In NPM based applications like nodejs, Angular, VueJS and ReactJS applications, package.json file location is the application root


You are giving here Invalid authentication credentials Please check for valid credentials and then again try

you will get an api key like : TRN-Api-Key: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX example : TRN-Api-Key: 17012661-57fa-45fa-bbdf-xxxxxxxxxxxx

How to read and write JSON file using Node.js ?, Method 1: Using require method: The simplest method to read a JSON file is to require it in a node.js file using require() method. Syntax: Express is one of the most popular web frameworks for Node.js - probably used by most Node.js developers. It's an excellent framework that has a myriad of HTTP utility methods, and it also performs well. When working with Express, we get access to a request and a response object, and we can use the latter to send some response back to the


Parsing JSON with Node.js, to parse JSON from a string, and how to read a JSON file in Node.js. so if you call it again because you updated the file, you won't get the� The JSON.stringify() method converts a JavaScript object or value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.


How to parse JSON using Node.js?, Find out how your platform does it, and use process.env to retrieve the config vars from within the code. Parsing a string containing JSON data. var str� A simple explanation of the peerDependencies field in the package.json file Published Dec 12, 2019 In some package.json files, you might see a few lines like this:


JSON.parse(), The JSON.parse() method parses a JSON string, constructing the JavaScript value or object JSON.parse() does not allow trailing commas. First, you will create a package.json file to store useful metadata about the project and help you manage the project’s dependent Node.js modules. As the suffix suggests, this is a JSON (JavaScript Object Notation) file. JSON is a standard format used for sharing, based on JavaScript objects and consisting of data stored as key-value pairs.