# NodeJS -------------------------------------------------------------------------------- title: "Introduction" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.685Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/introduction/" service: "All Services" related: - Project Directory Structure (/en/cli/v1/project-directory-structure/introduction/) - News API (https://newsapi.org/) -------------------------------------------------------------------------------- # NewsApp ### Introduction In this tutorial, we will create a news application called **The Daily Broadcast**, which retrieves the latest news from multiple trusted sources, refreshes the content at defined time intervals, and displays the updated news within the application. For this purpose, we will use the {{%link href="https://newsapi.org/"%}}NewsAPI{{%/link%}}, a third-party service that fetches headlines across various categories such as Business, Entertainment, Health, Science, Sports, and Technology from sources around the web. We will integrate this API into our application and display the news along with links to the original articles. The final look of the client application will resemble this screen: You can access the working application from here : {{%link href="https://news-fetcher.catalystserverlessapp.com/app/"%}}Try the App!{{%/link%}} We will build the news application using the following Catalyst Services and their Components, each playing a key role in the overall architecture: 1. {{%link href="/en/serverless/getting-started/introduction/" %}}**Catalyst Serverless**{{%/link%}}: - **{{%link href="/en/serverless/help/functions/advanced-io/"%}}Advanced I/O Function{{%/link%}}** : This function is coded in **NodeJS** and serves as the API layer of the application. It retrieves news data from the Catalyst Cloud Scale Data Store and delivers it to the frontend as a JSON response. - **{{%link href="/en/serverless/help/functions/job-functions/"%}}Job Function{{%/link%}}** : This function is coded in NodeJS and contains the logic to call the {{%link href="https://newsapi.org/"%}}NewsAPI{{%/link%}}, fetch the latest headlines across different categories, and store them in the Data Store. 2. {{%link href="/en/cloud-scale/getting-started/introduction/" %}}**Catalyst Cloud Scale**{{%/link%}}: - **{{%link href="/en/cloud-scale/help/data-store/introduction/"%}}Data Store{{%/link%}}** : This component acts as the central storage for all news data fetched from the {{%link href="https://newsapi.org/"%}}NewsAPI{{%/link%}}. It ensures fast and scalable access to news content. - **{{%link href="/en/cloud-scale/help/zcql/introduction/"%}}ZCQL{{%/link%}}** : This component is used to query the Data Store efficiently and retrieve the relevant news data. - **{{%link href="/en/cloud-scale/help/web-client-hosting/introduction/"%}}Web Client Hosting{{%/link%}}** : This component hosts the frontend of the application, allowing users to view the news content seamlessly through a web interface. 3. **{{%link href="/en/job-scheduling/getting-started/introduction/"%}}Catalyst Job Scheduling{{%/link%}}**: This component enables periodic execution of the Job Function, ensuring the application is updated with fresh news at defined intervals. Together, these components enable a fully functional, automated news application that stays up-to-date with the latest information from reliable sources. We will use the Catalyst web console and the Catalyst Command Line Interface (CLI) to build this application. You will be given the code for the files to be included in the function and client components in this tutorial. You will just have to copy the code given in this guide and paste it into the appropriate files as directed. ### Application Architecture The News application architecture is depicted in the workflow diagram below: -------------------------------------------------------------------------------- title: "Prerequisites" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.685Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/prerequisites/" service: "All Services" related: - CLI Command Reference (/en/cli/v1/cli-command-reference/) -------------------------------------------------------------------------------- # Prerequisites Before you begin building the application, you must have the following prerequisites installed on your system: {{%list class="bold"%}}1. **Catalyst CLI** \ \ Catalyst CLI contains a host of tools that enable you to initialize, develop, test, and deploy the components of your application from your local machine. We will be working with Catalyst CLI in this tutorial. \ \ You must perform the following actions: 1. **Install Catalyst CLI:** Catalyst CLI is installed through NPM. You must therefore have NPM and Node.js installed on your system before you install the CLI. Refer to the {{%link href="/en/getting-started/installing-catalyst-cli/" %}}**Install Catalyst CLI help page**{{%/link%}} for details on the pre-requisites and the steps to install it. 2. **Log in to Catalyst CLI:** After you install Catalyst CLI, you must authenticate the CLI with your Catalyst account before using it. Refer to the {{%link href="/en/cli/v1/login/login-from-cli/" %}}**CLI Login help page**{{%/link%}} for the steps to login from Catalyst CLI and the various options available for it. <br> <br> {{%/list%}} {{%list class="bold"%}}2. **Any IDE tool for Node.js function and client code development** \ \ You can use any IDE to work with the Advanced I/O function and the client code. Some popular choices include Visual Studio Code, IntelliJ IDEA, Eclipse, and Sublime Text. Download and install an IDE of your choice on your system.{{%/list%}} {{%info image="/images/tutorials/todo-list/vscode.png"%}}If you are a Visual Studio Code IDE user, you can install the {{%bold%}}Catalyst Tools{{%/bold%}} extension, and use your IDE itself in place of the CLI. You can find more details about the Catalyst VS Code extension from this {{%link href="/en/catalyst-extensions/vs-code-extension/introduction/" %}}help section{{%/link%}}.{{%/info%}} -------------------------------------------------------------------------------- title: "Create a project" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.685Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/create-project/" service: "All Services" related: - Project Directory (/en/cli/v1/project-directory-structure/introduction) - Setup Catalyst Projects (/en/getting-started/catalyst-projects) -------------------------------------------------------------------------------- # Create a Project Let's {{%link href="/en/getting-started/catalyst-projects/"%}}create a Catalyst Project{{%/link%}} from the Catalyst console. 1. Log in to the {{%link href="https://console.catalyst.zoho.com/baas/index"%}}Catalyst Console{{%/link%}} and click **Create New Project**. <br /> 2. Enter the project's name as "**NewsApp**" in the pop-up window and click **Create**. <br /> Your project will be created and opened automatically. -------------------------------------------------------------------------------- title: "Create tables" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.685Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/create-tables/" service: "All Services" related: - Data Store (/en/cloud-scale/help/data-store/introduction) -------------------------------------------------------------------------------- # Create Tables in the Data Store Next, let's create tables in the {{%link href="/en/cloud-scale/help/data-store/introduction/" %}}Catalyst Cloud Scale Data Store{{%/link%}} of the NewsApp project. We will be creating seven tables to store news of various news categories. Let's begin by creating the first table. To create a table, please follow the below-listed steps: 1. Navigate to the {{%link href="/en/cloud-scale/getting-started/introduction/" %}}Cloud Scale service{{%/link%}} from the Catalyst console, and click **Start Exploring**. <br /> 2. Navigate to **Data Store** under the **Storage** section and click **Create a new Table**. <br /> 3. Enter the table's name as '**HEADLINES**' and click **Create**. <br /> This table will store the general headlines of the news items obtained through {{%link href="https://newsapi.org/"%}}NewsAPI{{%/link%}}. {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: Ensure that you enter the name exactly as instructed, because the application's code contains the same name.{{%/note%}} The table is now created and displayed on the {{%italics%}}Data Store{{%/italics%}} page. <br /> Click on **New Table** to create the other tables in the same way. <br /> We will need to create six other tables to store news data of varied categories and name them as follows: 'BUSINESS', 'ENTERTAINMENT', 'HEALTH', 'SCIENCE', 'SPORTS', 'TECHNOLOGY'. {{%note%}}{{%bold class="bold-primary"%}}Note{{%/bold%}}: Ensure that you enter all the table names exactly as instructed, because the application's code contains the same names.{{%/note%}} The tables will be displayed on the left in the **Data Store** page. <br /> ### Create Columns Now, let's create columns in all the tables. We will create two columns in each table: * **title**: To store the title of the news article * **url**: To store the original URL of the news article's source To create a column in a table, please make sure to follow the below steps: 1. Click **New Column** in the {{%italics%}}Schema View{{%/italics%}} section for the table. <br /> 2. Enter the column's name as '**title**'. Select the data type as **Var Char**, enter the max length as '**255**' and click **Create**. <br /> You can learn about the various data types supported by Catalyst and the other properties of a column from the {{%link href="/en/cloud-scale/help/data-store/introduction"%}}Data Store help page{{%/link%}}. {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: Ensure that you enter the name exactly as instructed, because the application's code contains the same name.{{%/note%}} Now create the **'url'** column in the same way. Provide the same values and click **Create**. <br /> The columns are now created for the table and will be listed in the {{%italics%}}Schema View{{%/italics%}} section. <br /> Now create the same columns with the same values in each of the other six tables. We have now configured the Data Store. We will work on coding the application from our local system. We will configure the Job Scheduling service later. -------------------------------------------------------------------------------- title: "Create a Job Pool" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.714Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/create-job-pool/" service: "All Services" related: - Job Scheduling (/en/job-scheduling/getting-started/introduction/) -------------------------------------------------------------------------------- # Create a Job Pool Let's now {{%link href="/en/job-scheduling/help/implementation/create-jobpool/"%}}create a job pool{{%/link%}} using the {{%link href="/en/job-scheduling/getting-started/introduction/"%}}Catalyst Job Scheduling service{{%/link%}}. This component is responsible for executing jobs and triggering the {{%link href="/en/serverless/help/functions/job-functions/"%}}job function{{%/link%}} that we will configure in {{%link href="/en/tutorials/newsapp/nodejs/configure-job-function"%}}Step 5{{%/link%}}. We will configure a {{%link href="/en/job-scheduling/help/implementation/submit-job-predefined-cron/"%}}predefined cron{{%/link%}} schedule to automatically submit jobs to the job pool at regular intervals (say once in every hour). You can learn more about the job execution in a job pool from {{%link href="/en/job-scheduling/help/jobpool/introduction/#architecture-of-job-execution-in-a-job-pool"%}}this help page{{%/link%}}. To create a job pool, please ensure to follow the below-listed steps: 1. Navigate to the **Job Scheduling** service in the Catalyst console. <br /> 2. Navigate to **Job Pool** under the **Job Source** section and click **Create Job Pool**. In the pop-up window, provide the Job Pool name as **"News"** and select the Job Pool Type as **Function** (this is typically the job function we will be configuring in {{%link href="/en/tutorials/newsapp/nodejs/configure-job-function"%}}Step 5{{%/link%}}). You can select the required compute memory for the function. In our case, as an upper limit you can select up to 2GB and click **Create**. <br /> The job pool is now created. -------------------------------------------------------------------------------- title: "Initialize the project" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.714Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/initialize-project/" service: "All Services" related: - Project Directory Structure (/en/cli/v1/project-directory-structure/introduction/) - Initialize Resources (/en/cli/v1/initialize-resources/introduction/) - Advanced I/O Functions (/en/serverless/help/functions/advanced-io/) - Job Functions (/en/serverless/help/functions/job-functions/) -------------------------------------------------------------------------------- # Initialize the Project from the CLI You can now begin working on your Catalyst project from the CLI. The first step is to initialize the project in an empty directory. This will be the home directory of your project and all of the project files will be saved in it. You can learn more about this from the {{%link href="/en/cli/v1/project-directory-structure/introduction/"%}}Project Directory Structure help page{{%/link%}}. You can learn about initializing a project in detail from the {{%link href="/en/cli/v1/initialize-resources/introduction/"%}}CLI help documentation{{%/link%}}. For the news application, we will initialize a {{%link href="/en/serverless/help/functions/job-functions/"%}}job function{{%/link%}} and the {{%link href="/en/cli/v1/working-with-the-client/introduction/"%}}client{{%/link%}}, and then {{%link href="/en/serverless/help/functions/advanced-io"%}}add an Advanced I/O function{{%/link%}} to the project directory. 1. Create a folder for the project on your local machine and navigate to it from the terminal. Initialize a project by executing the following command from that directory: {{%cli%}}catalyst init {{%/cli%}} 2. The CLI will now ask you to select the organization in which your Catalyst project that we created earlier in the console resides. Select the organization and press **Enter**. <br /> 3. Select the project in the organization from the list and press **Enter**. <br /> 4. Select **Functions** and **Client** using the space bar. Press **Enter** to initialize the components. <br /> 5. The CLI will first initiate the function setup. Select **Job** as the function type. <br /> 6. Select the latest runtime of **Node.js** as the function stack. <br /> 7. Enter **'NewsApp'** as the package name, **'index.js'** as the entry point, and your email address as the author and press Enter. You can press **Enter** to fill in the default values. The CLI will prompt the initialization of the Node dependencies. Press **Y** to confirm the installation, and press **Enter** to confirm your choice. The Node modules will be installed. <br /> 8. The CLI will now initialize the client set up. Choose **"Basic web app"** as the client type. <br /> 9. Enter **'NewsAppClient'** as the name for the client package and press **Enter**. You can enter any name you want. <br /> The client directory will be created in the standard structure. Catalyst initialization is now complete. Let's now add an additional Advanced I/O function to the project directory. As mentioned earlier, we will be coding it in **Node.js** stack. 1. To add an additional function, execute the following command from the project directory: {{%cli%}}catalyst functions:add{{%/cli%}} 2. Select **AdvancedIO** as the function type and press **Enter**. <br /> 3. Select the latest runtime of Node.js as the function stack, and press **Enter**. <br /> 4. Enter "**news_app_function**" as the package name, "**index.js**" as the entry point, and your email address as the author and press Enter. You can press **Enter** to fill the default values. The CLI will prompt the initialization of the Node dependencies. Press **Y** to confirm the installation, and press **Enter** to confirm your choice. The Node modules will be installed. <br /> {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: Ensure that you enter the package name, or class name and folder name, exactly as instructed, because the application's code contains the same names.{{%/note%}} Your project directory is now set up with the {{%link href="/en/cli/v1/project-directory-structure/client-directory"%}}client directory{{%/link%}} and the {{%link href="/en/cli/v1/project-directory-structure/functions-directory"%}}functions directory{{%/link%}} along with configuration files and dependencies. The functions directory contains both the Job and Advanced I/O functions in individual folders. The project directory also contains the {{%link href="/en/cli/v1/project-directory-structure/catalyst-json"%}}{{%badge%}}catalyst.json{{%/badge%}}{{%/link%}} configuration file and a hidden {{%badge%}}.catalystrc{{%/badge%}} file. The structure of the NewsApp project's directory will look like this: -------------------------------------------------------------------------------- title: "Configure the Job function" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.715Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/configure-job-function/" service: "All Services" related: - Job Scheduling (/en/job-scheduling/getting-started/introduction/) - Job Functions (/en/serverless/help/functions/job-functions/) -------------------------------------------------------------------------------- # Configure the Job Function Next, we'll begin coding the news application by configuring the job function component. The function's directory, in this case {{%badge%}}functions/NewsApp{{%/badge%}}, contains: * The {{%badge%}}index.js{{%/badge%}} main function file * The {{%badge%}}catalyst-config.json{{%/badge%}} configuration file * Node modules * {{%link href="https://docs.npmjs.com/files/package.json"%}}{{%badge%}}package.json{{%/badge%}}{{%/link%}} and {{%link href="https://docs.npmjs.com/configuring-npm/package-lock-json.html"%}}{{%badge%}}package-lock.json{{%/badge%}}{{%/link%}} dependency files We will be adding code in the {{%badge%}}index.js{{%/badge%}} file. You will not be modifying the code of the configuration and dependency files. As mentioned in the {{%link href="/en/tutorials/newsapp/nodejs/introduction/"%}}introduction{{%/link%}}, the job function performs two tasks: making the API calls to the {{%link href="https://newsapi.org/"%}}NewsAPI{{%/link%}} to fetch news, populating the news in Catalyst Data Store. The API calls are made using an API key provided by NewsAPI. ### Register with NewsAPI Before you code the job function, you must register for a free developer subscription with NewsAPI and obtain the API key in the following way: 1. Visit {{%link href="https://newsapi.org/register"%}}https<span></span>://newsapi.org/register{{%/link%}}. 2. Provide the required details and click **Submit**. After your registration is complete, NewsAPI will provide you with an API key. You must use this in your cron function, as instructed after the code section. ### Install Packages for Node.js The Node.js Cron function requires two packages to be installed: {{%link href="https://www.npmjs.com/package/express"%}}{{%badge%}}express{{%/badge%}}{{%/link%}} and {{%link href="https://www.npmjs.com/package/axios"%}}{{%badge%}}axios{{%/badge%}}{{%/link%}}. {{%badge%}}**express**{{%/badge%}} We will use the Express framework to manage the routing operations that enable us to fetch and delete files. To install {{%badge%}}express{{%/badge%}}, navigate to the function's directory ({{%badge%}}functions/NewsApp{{%/badge%}}) in your terminal and execute the following command: {{%cli%}}npm install express{{%/cli%}} This will install the Express module and save the dependencies. {{%badge%}}**axios**{{%/badge%}} {{%badge%}}axios{{%/badge%}} is a promise-based HTTP client that we will use to fetch data by executing the NewsAPI. To install {{%badge%}}axios{{%/badge%}}, navigate to the Node function's directory ({{%badge%}}functions/NewsApp{{%/badge%}}) and execute the following command: {{%cli%}}npm install axios{{%/cli%}} This will install the module. You can copy the code below and paste it in index.js located in the {{%badge%}}functions/NewsApp{{%/badge%}} directory of your project and save the file. You can use any IDE to work with the application's files. {{%note%}}{{%bold class="bold-primary"%}}Note{{%/bold%}}: Please go through the code given in this section to make sure you fully understand it.{{%/note%}} {{% panel_with_adjustment header="index.js" footer="button" class="language-javascript line-numbers" scroll="set-scroll" %}}/** * * @param {import("./types/job").JobRequest} jobRequest * @param {import("./types/job").Context} context */ const catalyst = require("zcatalyst-sdk-node"); const axios = require('axios'); const HOST = "https://newsapi.org"; const TABLENAME = [ "HEADLINES", "BUSINESS", "ENTERTAINMENT", "HEALTH", "SCIENCE", "SPORTS", "TECHNOLOGY", ]; const COUNTRY = "US"; const APIKEY = "cc30ddcae1684e848f08ed474f6aaf0e"; const DATASTORE_LOAD = 5; const pushNewstoDatastore = async ({ table, rowIds, articles }) => { return Promise.all( articles.map(async (article, idx) => { const payload = { title: article.title, url: article.url, }; if (rowIds.length === 0) { //insert the new row return table.insertRow(payload); } return table.updateRow({ &#46;&#46;&#46;payload, ROWID: rowIds[idx] }); }) ); }; module.exports = async (jobRequest, context) => { try{ console.log('Execution started'); const catalystApp = catalyst.initialize(context); const zcqlAPI = catalystApp.zcql(); const datastoreAPI = catalystApp.datastore(); const metaArr = await Promise.all( TABLENAME.map(async (table) => { //construct request path to newsapi let url = `${HOST}/v2/top-headlines?country=${COUNTRY}&apiKey=${APIKEY}`; if (table !== TABLENAME[0]) { url += "&category=" + table; } const response = await axios({ method: "GET", url }); let data = response.data; //query using zcql to check if row exists const queryResult = await zcqlAPI.executeZCQLQuery( `SELECT ROWID FROM ${table}` ); return { table_name: table, table: datastoreAPI.table(table), zcql_response: queryResult, articles: data.articles.splice(0, 15), }; }) ); //sync insert/update to datastore for (const meta of metaArr) { let rowIds = []; while (meta.articles.length > 0) { const chunk = meta.articles.splice(0, DATASTORE_LOAD); if (meta.zcql_response.length > 0) { rowIds = meta.zcql_response .splice(0, DATASTORE_LOAD) .map((row) => row[meta.table_name].ROWID); } await pushNewstoDatastore({ ...meta, articles: chunk, rowIds }); } console.log( `${meta.table} table ${ rowIds.length === 0 ? "inserted" : "updated" } with current news'` ); } context.closeWithSuccess(); //end of application with success }catch(err){ console.log("Error :: "+err); context.closeWithFailure(); //end of application with failure }; }; {{% /panel_with_adjustment %}} {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: After you copy and paste this code in your function file, ensure that you replace value of {{%badge%}}**APIKEY**{{%/badge%}} in the line {{%bold%}}19{{%/bold%}} with the API key you obtained from NewsAPI.{{%/note%}} The job function is now configured. We will discuss the application's architecture after we configure the client. -------------------------------------------------------------------------------- title: "Configure the Advanced I/O function" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.716Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/configure-advancedio/" service: "All Services" related: - Advanced I/O Function (/en/serverless/help/functions/advanced-io) - Data Store (/en/cloud-scale/help/data-store/introduction) - ZCQL (/en/cloud-scale/help/zcql/introduction) -------------------------------------------------------------------------------- # Configure the Advanced I/O Function The Advanced I/O function directory ({{%badge%}}functions/news_app_function{{%/badge%}}) contains the following files: * The {{%badge%}}index.js{{%/badge%}} main function file * The {{%badge%}}catalyst-config.json{{%/badge%}} configuration file * Node modules * {{%link href="https://docs.npmjs.com/files/package.json"%}}{{%badge%}}package.json{{%/badge%}}{{%/link%}} and {{%link href="https://docs.npmjs.com/configuring-npm/package-lock-json.html"%}}{{%badge%}}package-lock.json{{%/badge%}}{{%/link%}} dependency files. You will be adding code in the {{%badge%}}index.js{{%/badge%}} file. The Advanced I/O function fetches the news item from its source table in the Data Store and forwards it to the client component as a JSON response. ### Install Express Node.js Framework Since you are coding in the Node.js platform, you will be using the {{%link href="https://expressjs.com/"%}}{{%badge%}}Express Node.js{{%/badge%}}{{%/link%}} framework. To import the Express package in the code, you must install the Express dependencies in your system. {{%cli%}}npm install express{{%/cli%}} This will install the Express module and save the dependencies. Copy the Node.js code and paste it in {{%badge%}}index.js{{%/badge%}} in {{%badge%}}functions/news_app_function{{%/badge%}} directory of your project, and save the file. You can use any IDE to work with the application's files. {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: Please go through the code in this section to make sure you fully understand it.{{%/note%}} {{% panel_with_adjustment header="index.js" footer="button" class="language-javascript line-numbers" scroll="set-scroll" %}}'use strict'; var express = require('express'); var app = express(); var catalyst = require('zcatalyst-sdk-node'); app.use(express.json()); //GET API that gets the news from the required table app.get('/fetchData', (req, res) => { var tablename = req.query.tablename; console.log("Table Name "+tablename); //Initializing Catalyst SDK var catalystApp = catalyst.initialize(req); //Queries the Catalyst Data Store table and gets the required news getDataFromCatalystDataStore(catalystApp, tablename).then(newsDetails => { res.send({ "content": newsDetails }) }).catch(err => { console.log(err); sendErrorResponse(res); }) }); /** * Executes the Query and fetches the news from the table * @param {*} catalystApp * @param {*} tablename */ function getDataFromCatalystDataStore(catalystApp, tablename) { return new Promise((resolve, reject) => { //Queries the Catalyst Data Store table catalystApp.zcql().executeZCQLQuery("Select title,url from " + tablename).then(queryResponse => { resolve(queryResponse); }).catch(err => { reject(err); }) }); } /** * Sends an error response * @param {*} res */ function sendErrorResponse(res) { res.status(500); res.send({ "error": "Internal server error occurred. Please try again in some time." }); } module.exports = app; {{% /panel_with_adjustment %}} The Advanced I/O function is now configured. We will discuss the application's architecture after we configure the client. -------------------------------------------------------------------------------- title: "Configure the client" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.736Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/configure-client/" service: "All Services" related: - Client (/en/cli/v1/project-directory-structure/introduction) - Advanced I/O Function (/en/serverless/help/functions/advanced-io) -------------------------------------------------------------------------------- # Configure the Client Let's now configure the client component. The {{%link href="/en/cli/v1/project-directory-structure/introduction"%}}directory{{%/link%}} contains: * The {{%badge%}}index.html{{%/badge%}} file that contains the HTML code for the frontend application * The {{%badge%}}main.css{{%/badge%}} file that contains the CSS code * The {{%badge%}}main.js{{%/badge%}} file that contains the JavaScript code * The {{%badge%}}client-package.json{{%/badge%}} configuration file We will be coding {{%badge%}}index.html{{%/badge%}}, {{%badge%}}main.js{{%/badge%}}, and {{%badge%}}main.css{{%/badge%}}. {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: Please go through the code in this section to make sure you fully understand it.{{%/note%}} Copy the code below and paste it in the respective files located in the {{%badge%}}client/{{%/badge%}} directory of your project using an IDE and save the files. {{% panel_with_adjustment header="index.html" footer="button" class="language-xml line-numbers" scroll="set-scroll" %}}&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;title&gt;NewsApp&lt;/title&gt; &lt;script src="main.js"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" media="screen" href="main.css" /&gt; &lt;head&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;/head&gt; &lt;body onload="fetchNews('HEADLINES')"&gt; &lt;center&gt; &lt;h1&gt;Welcome to The Daily Broadcast&lt;/h1&gt; &lt;h3&gt;Today's News&lt;/h3&gt; &lt;h2&gt;HEADLINES&lt;/h2&gt;&lt;br&gt; &lt;/center&gt; &lt;div class="sidenav"&gt; &lt;img src="https://i.pinimg.com/236x/e6/71/5f/e6715f8bd963c783f75f11fdc37fa4aa.webp" width="220" height="200" onclick="fetchNews('HEADLINES')"&gt;&lt;br&gt; &lt;a onclick="return fetchNews('BUSINESS');"&gt;Business&lt;/a&gt;&lt;br&gt; &lt;a onclick="return fetchNews('ENTERTAINMENT');"&gt;Entertainment&lt;/a&gt;&lt;br&gt; &lt;a onclick="return fetchNews('HEALTH');"&gt;Health&lt;/a&gt;&lt;br&gt; &lt;a onclick="return fetchNews('SCIENCE');"&gt;Science&lt;/a&gt;&lt;br&gt; &lt;a onclick="return fetchNews('SPORTS');"&gt;Sports&lt;/a&gt;&lt;br&gt; &lt;a onclick="return fetchNews('TECHNOLOGY');"&gt;Technology&lt;/a&gt;&lt;br&gt; &lt;/div&gt; &lt;div class="loading" id="loader" style="display: none;"&gt;&lt;/div&gt; &lt;div class="main"&gt; &lt;ul id="newsList"&gt;&lt;/ul&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; {{% /panel_with_adjustment %}} {{% panel_with_adjustment header="main.css" footer="button" class="language-css line-numbers" scroll="set-scroll" %}}.sidenav { height: 100%; width: 220px; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; } a{ cursor: pointer; } .sidenav a { padding: 6px 8px 6px 16px; text-decoration: none; font-size: 25px; font-family: "Helvetica", sans-serif; color: #818181; display: block; } .sidenav a:hover { color: #f1f1f1; } .main { margin-left: 200px; font-size: 20px; padding: 0px 10px; font-family: "Poynter", sans-serif; } @media screen and (max-height: 450px) { .sidenav { padding-top: 15px; } .sidenav a { font-size: 18px; } } .loading { height: 0; width: 0; padding: 15px; border: 6px solid rgb(155, 155, 155); border-right-color: rgb(88, 88, 88); border-radius: 22px; -webkit-animation: rotate 1s infinite linear; /* left, top and position just for the demo! */ position: absolute; left: 50%; top: 50%; } @-webkit-keyframes rotate { /* 100% keyframe for clockwise. use 0% instead for anticlockwise */ 100% { -webkit-transform: rotate(360deg); } } {{% /panel_with_adjustment %}} {{% panel_with_adjustment header="main.js" footer="button" class="language-javascript line-numbers" scroll="set-scroll" %}}function fetchNews(name) { //Since we display the news items as nodes, removes the existing nodes for every category change const nodes = document.getElementById("newsList"); nodes.innerHTML = ''; document.getElementById("loader").style.display = "block"; var tablename = name; console.log(tablename); //Makes an API call to the Advanced I/O function to fetch the news item from a particular table $.ajax({ url: "/server/news_app_function/fetchData?tablename=" + tablename, //If you initialized the Advanced I/O function with a different name, ensure you replace news_app_function with that name. type: "get", success: function (response) { var data = response; var i; document.getElementById("loader").style.display = "none"; //Parses the response from the Advanced I/O function, and renders it in the HTML page by creating a list of nodes for (i = 0; i < data.content.length; i++) { var list = document.getElementById('newsList'); var anchor = document.createElement('a'); var li = document.createElement('li'); var linebreak = document.createElement("br"); anchor.href = data.content[i][tablename].url; anchor.innerText = data.content[i][tablename].title; anchor.setAttribute('target', '_blank'); li.appendChild(anchor); list.appendChild(li); list.appendChild(linebreak); } }, error: function (error) { alert(error.data); } }); } {{% /panel_with_adjustment %}} {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: If you have chosen a different name for your Advanced I/O function, then replace {{%bold%}}news_app_function{{%/bold%}} with that name in line {{%bold%}}10{{%/bold%}}.{{%/note%}} The client directory is now configured. ### Working of Functions and Client Let us quickly go through the working of the function and client components of the application: * When a recursive cron is configured to execute in a specified time interval say once every hour and associated with the job function {{%badge%}}newsapp{{%/badge%}}, it automatically initiates the function's execution once every hour. * An API call to http://newsapi.org/v2/top-headlines is made to fetch the news headlines. This request is authenticated using the API key obtained from NewsAPI. The choice of country, the API key, and the news category associated with the respective table in the Data Store are passed as query parameters. * The {{%badge%}}pushNewstoDatastore{{%/badge%}} method inserts the data obtained from the API call for the {{%badge%}}title{{%/badge%}} and {{%badge%}}url{{%/badge%}} parameters into a list. A {{%link href="/en/cloud-scale/help/zcql/introduction"%}} ZCQL query{{%/link%}} then obtains the row count of each table. If data is already populated in a table from a previous API call made to NewsAPI, the data is replaced with the updated news items. If no rows exist, new data is pushed to the table. * The script defined in the client component {{%badge%}}main.js{{%/badge%}} makes an API call to the Advanced I/O function by executing a {{%badge%}}GET{{%/badge%}} request to the route {{%badge%}}/fetchData{{%/badge%}} defined in the function. The table names are passed in the request URL. * The Advanced I/O function queries the relevant tables in the Data Store and obtains the {{%badge%}}title{{%/badge%}} and {{%badge%}}url{{%/badge%}} of the news items. This is constructed as a JSON response and passed back to {{%badge%}}main.js{{%/badge%}}. * {{%badge%}}main.js{{%/badge%}} parses the JSON response obtained from the function and renders it in the HTML page by creating a list of nodes. -------------------------------------------------------------------------------- title: "Test the application" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.736Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/test-application/" service: "All Services" related: - Serve Resources (/en/cli/v1/serve-resources/introduction/) -------------------------------------------------------------------------------- # Test the Application Before you deploy the application to the remote console, you can test the application on a local server and check if everything works fine using the Catalyst CLI. We will first test the cron function using the {{%link href="/en/cli/v1/working-with-functions/functions-shell/"%}}functions shell{{%/link%}} in the CLI, and then {{%link href="/en/cli/v1/serve-resources/introduction/"%}}serve the Advanced I/O function and the client locally{{%/link%}} to test the frontend of the application. Let's first execute the below command to generate a sample payload to pass in the functions shell which we will be accessing later: {{%cli%}}catalyst event:generate:job 10108000007982015 // Replace with the required Job Pool ID{{%/cli%}} The generated payload will look like this : Now open the functions shell in your CLI by executing the following command from your project directory (CATALYST_PROJECT_HOME): {{%cli%}}catalyst functions:shell{{%/cli%}} This will open the functions shell for the cron function in the CLI where you can test its execution. To invoke the function, enter {{%badge%}}**newsapp()**{{%/badge%}} in the shell, pass the generated payload within the braces and press **Enter**. When testing the Job Function using the shell command, the response indicates the execution status of the function, either {{%badge%}}success{{%/badge%}} or {{%badge%}}failure{{%/badge%}}. The function's execution status is returned as success. This will make the API call to NewsAPI and fetch the news items from each category, and populate them in the Data Store. You can check the Data Store component if the data has been populated as expected. Now, let's host the client component locally and check the frontend of the application. To serve the Catalyst project locally, execute the following command from your project directory (CATALYST_PROJECT_HOME): {{%cli%}}catalyst serve{{%/cli%}} The news application will now be served at default port 3000. The local endpoint URLs of the components (the client and the Advanced I/O function) are displayed. {{%note%}} {{%bold class="bold-primary"%}}Note{{%/bold%}}: Every time you access the homepage or any of the sub-pages of your client or the function, the CLI will display a live log of the URL accessed, along with the HTTP request method.{{%/note%}} You can now open the application in a browser using the local URL of the client displayed in the CLI. The news application displays the general news headlines on the index page. You can click a topic on the left to check the latest headlines in that category. You can open the original news article by clicking on a headline. If this setup is working correctly, we can deploy the application to the console. -------------------------------------------------------------------------------- title: "Deploy the project" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.736Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/deploy-application/" service: "All Services" related: - Deploy Resources (/en/cli/v1/deploy-resources/) -------------------------------------------------------------------------------- # Deploy the Project To {{%link href="/en/cli/v1/deploy-resources/introduction/"%}}deploy your Catalyst project from the CLI{{%/link%}}, run the following command in your terminal from your project directory (CATALYST_PROJECT_HOME): {{%cli%}}catalyst deploy{{%/cli%}} The functions are deployed first, followed by the client component. The production URLs of the components are displayed. You can now open the client component's URL in a browser to access the deployed application. The news application can now be accessed from its {{%link href="/en/cloud-scale/help/web-client-hosting/introduction"%}}web app URL{{%/link%}}. -------------------------------------------------------------------------------- title: "Schedule a cron" description: "Build a web news application that automatically fetches news from a third-party service periodically using the Catalyst Job Scheduling Cron component, and a Job Function and Advanced I/O function coded in Node.js." last_updated: "2026-03-18T07:41:08.736Z" source: "https://docs.catalyst.zoho.com/en/tutorials/newsapp/nodejs/schedule-cron/" service: "All Services" related: - Job Scheduling Cron (/en/job-scheduling/help/cron/introduction/) - Job Functions (/en/serverless/help/functions/job-functions/) -------------------------------------------------------------------------------- # Schedule a Cron Next, let’s {{%link href="/en/job-scheduling/help/cron/introduction/"%}}create a cron{{%/link%}}, associate it with the Job Pool created in {{%link href="/en/tutorials/newsapp/nodejs/create-job-pool/"%}}Step 3{{%/link%}}, and schedule it to run every hour. This cron will trigger the {{%link href="/en/tutorials/newsapp/nodejs/configure-job-function/"%}}Job Function{{%/link%}} periodically to fetch the latest news from the {{%link href="https://newsapi.org/"%}}NewsAPI {{%/link%}} and update the application. By running once every hour, the cron ensures that the application remains up to date with fresh news content. Each time it runs, it automatically invokes the Job Function, which makes an API call to the NewsAPI to retrieve the latest headlines. To create a cron from the Catalyst console, please make sure to follow the below-listed steps: 1. Navigate to **Cron** under the **Job Executor** section and click **Create Cron**. 2. Enter a name and a description for the cron. You can enter any name. Select the **Format Type** as **Standard Input**. Select the **Schedule Type** as **Recursive**. Select the **Repeat Type** as **Every**.You can set the **Schedule Time** as required and also choose to enable the **Cron termination details**. After entering all the details, click **Next**. 3. Provide a name for the Job, select the Job Pool as News and the target function as **newsapp**. Click **Create**. The cron has been created successfully. You can now submit the job to start its execution by clicking on the **Submit Job** button. You can click on **Execution History** button to view the cron execution details. You can navigate to the **Jobs** section and view the execution status of the jobs scheduled in the cron for every hour. The news application is now functional and the news will be fetched from the NewsAPI and updated in the application for every one hour.