How to check for a null value in an element of a json object in node js function?

How to check for a null value in an element of a json object in node js function?

I am using&nbsp;<a href="https://github.com/facundoolano/google-play-scraper" target="_blank">google-play-scraper</a>&nbsp;module in node.js to scrape google play reviews. The review function for a single page is as below:

I am using google-play-scraper module in node.js to scrape google play reviews. The review function for a single page is as below:

var gplay = require('google-play-scraper');
gplay.reviews({
  appId: 'es.socialpoint.chefparadise',
  page: 0,
  }).then(console.log, console.log);

Now, I like to scrape all the comments on all pages at once and save them in a logger. For this, I am using winston logger and a for loop as below:

var gplay = require('google-play-scraper');
const winston= require('winston');

const logger = winston.createLogger({ transports: [ new winston.transports.Console(), new winston.transports.File({ filename: 'rev1.log' }) ] }); package_id='com.jetstartgames.chess' for (i=0; i<112; i++){

gplay.reviews({
appId: package_id,
page: i,
}).then(logger.info, logger.info); 

}

The problem is that I should pre-defined the maximum number of pages that each application owns for its reviews (I should determine the maximum value of i for the loop). In order to do this, I taught of checking for the null value but I couldn't find a plausible way for doing it. The log file for a page that doesn't exist in reality has a structure as below:

{"message":[],"level":"info"}

I tried this code which doesn't work:

max=0
for (i=0; i<10000; i++){
 data=gplay.reviews({
    appId: 'com.jetstartgames.chess',
    page: i,
    });
    if (data.message==null || data.message==undefined){
        break;
    } else {
        max+=1;
    }
}

Is there any way that I can figure out the maximum number of pages by checking of the first null output? or any other suggestion for this purpose?

node-js json

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.

Hire Node.JS Developers | Skenix Infotech

We are providing robust Node.JS Development Services with expert Node.js Developers. Get affordable Node.JS Web Development services from Skenix Infotech.

Hands on with Node.Js Streams | Examples & Approach

The practical implications of having Streams in Node.js are vast. Nodejs Streams are a great way to handle data chunks and uncomplicate development.

Node.js Performance: Node.js vs. Io.js

You may already be aware that Raygun uses Node.JS for our API nodes that receive your precious crash reporting data (we also do node.js crash reporting if you’re interested). We’ve peaked in the past at more than 110,000 requests per second coming...

Node.js Live | Node.js Docker Tutorial | Dockerizing Node.js App|Node.js Training|Edureka

🔥 Node.js Certification Training: https://www.edureka.co/nodejs-certification-training This Edureka video on 'Node.js Docker Tutorial' will help you in learn...