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?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.

Node.js for Beginners - Learn Node.js from Scratch (Step by Step)

Node.js for Beginners - Learn Node.js from Scratch (Step by Step) - Learn the basics of Node.js. This Node.js tutorial will guide you step by step so that you will learn basics and theory of every part. Learn to use Node.js like a professional. You’ll learn: Basic Of Node, Modules, NPM In Node, Event, Email, Uploading File, Advance Of Node.

Top 7 Most Popular Node.js Frameworks You Should Know

Node.js is an open-source, cross-platform, runtime environment that allows developers to run JavaScript outside of a browser. In this post, you'll see top 7 of the most popular Node frameworks at this point in time (ranked from high to low by GitHub stars).