I provided you my favourite.js,  store-controller.js, favourite.ejs, home-list.ejs and app.js file below respectively help me to resolve the issue of when I click on add to favourite on home card of Homes list page then it save null in favourite.json file instead actual of homeId.                                                                                                                 //  favourite.js -                                                                                                                                                                  // Core Module
const fs = require('fs');  // File System module to read/write files
const path = require('path');
const rootDir = require('../utils/pathUtil');

const favouriteDataPath = path.join(rootDir,  'data', 'favourite.json');


module.exports = class Favourite {
 
  static addToFavourite(homeId, callback) {
    Favourite.getFavourites(favourites => {
      // registeredHomes.push(this);
      if (favourites.includes(homeId)) {
        console.log('Home already in favourites');
        return callback();
      } else {
        favourites.push(homeId);
        fs.writeFile(favouriteDataPath, JSON.stringify(favourites), callback);
        }
      });
  }

  static getFavourites(callback) {
    fs.readFile(favouriteDataPath, (err, data) => { 
        callback(!err ? JSON.parse(data) : []);
    });
  }
 };

 
 //   store-controller.js -                                                                                                                                              const Favourite = require("../models/favourite");
const Home = require("../models/home");

exports.getIndex = (req, res, next) => {
   Home.fetchAll((registeredHomes) => {
    res.render("store/index", {
      registeredHomes: registeredHomes,
      pageTitle: "airbnb Home",
      currentPage: "index",
    });
  });
};

exports.getHome = (req, res, next) => {
   Home.fetchAll((registeredHomes) => {
    res.render("store/home-list", {
      registeredHomes: registeredHomes,
      pageTitle: "Homes List",
      currentPage: "home",
    });
  });
};


exports.getBookings = (req, res, next) => {
    res.render("store/bookings", {
      pageTitle: "My Bookings",
      currentPage: "bookings",
    });
};


exports.getFavouriteList = (req, res, next) => {
     Home.fetchAll((registeredHomes) => {
    res.render("store/favourite-list", {
      registeredHomes: registeredHomes,
      pageTitle: "My Favourites",
      currentPage: "favourites",
    });
     });
};

exports.postAddToFavourite = (req, res, next) => {
  console.log("Came to add to favourite ",req.body);
  Favourite.addToFavourite(req.body.homeId, error => {
    if(error){
      console.log("Error while marking favourite:", error);
     // res.redirect("/home");
    }
      res.redirect("/favourites");
  })
}


exports.getHomeDetails = (req, res, next) => {
  const homeId = req.params.homeId;
  Home.findById(homeId, (home) => {
    if (!home) {
      console.log("Home not found with id:", homeId);
      res.redirect("/home");
    } else{
        res.render("store/home-detail", {
          home: home,
    pageTitle: "Home Details",
    currentPage: "home",
    homeId: homeId,
  })
    }
  });
};


                                                                                                                                                                                   //  favourite.ejs -                                                                                                                                                                              <form action="/favourites" method="POST">
  <button type="submit" class="bg-green-300 p-2 hover:bg-green-500">Add to Favourite</button>
  <input type="hidden" name="id" value="<%= home.id %>">
</form>                                                                                                                                                                      //  home-list.ejs  -                                                                                                                                                                 

<%- include('../partials/head') %>
  </head>
  <body>
    <%- include('../partials/nav') %>
    <main class="container mx-auto bg-white shadow-lg rounded-lg p-8 mt-10 max-w-6xl">
      <h2 class="text-3xl text-red-500 font-bold text-center mb-6">
        Here are our registered homes:
      </h2>
      <div class="flex flex-wrap justify-center gap-6">
        <% registeredHomes.forEach(home => { %>
          <div class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition duration-300 w-full max-w-sm">
            <img src="<%= home.photoUrl%>" alt="<%= home.houseName %>" class="w-full h-48 object-cover">
            <div class="p-4">
              <h3 class="text-xl font-semibold text-gray-800 mb-2"><%= home.houseName %></h3>
              <p class="text-gray-600 mb-2"><i class="fas fa-map-marker-alt mr-2"></i><%= home.location %></p>
              <div class="flex justify-between items-center mb-2">
                <span class="text-lg font-bold text-red-500">Rs<%= home.price %> / night</span>
                <div class="flex items-center">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5 text-yellow-400 mr-1">
                    <path fill-rule="evenodd" d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z" clip-rule="evenodd" />
                  </svg>
                  <span class="text-gray-700"><%= home.rating %></span>
                </div>
              </div>
              <a class=" bg-blue-400 p-2 "  href="/home/<%= home.id %>">Details</a>
              <%- include('../partials/favourite', {home: home}) %>
            </div>
          </div>
        <% }) %>
      </div>
    </main>
  </body>
</html>                                                                                                                                                                                     //  app.js file -                                                                                                                                                                   // Core Module
const path = require('path');

// External Module
const express = require('express');

//Local Module
const storeRouter = require("./routes/storeRouter");
const hostRouter = require("./routes/hostRouter");
const rootDir = require("./utils/pathUtil");
const errorController = require("./controllers/errors");

const app = express();

app.set('view engine', 'ejs');
app.set('views', 'views');

app.use(express.urlencoded());
app.use(storeRouter);
app.use("/host", hostRouter);

app.use(express.static(path.join(rootDir, 'public')))

app.use(errorController.pageNotFound);

const PORT = 3000;
app.listen(PORT, () => {
  console.log(`Server running on address http://localhost:${PORT}`);
});