Vue.js async function passing variable as undefined

I’m encountering an issue in my Vue.js application where an async function is passing a variable as undefined even though it’s correctly defined before the function call.

I have an async function FETCH_DATA in my Vue.js application defined as follows:

async [FETCH_DATA](
  {
    rootGetters,
  },
  { dataList, retries = 3 },
) {
  // Code to fetch data
},

This function is called from another method handleSubmission, where the itemList variable is correctly defined and logged before the call to FETCH_DATA. Here’s the relevant part of the code:

async handleSubmission(successResponse) {
  const { itemId } = successResponse;
  if (successResponse.isPromotional) {
    const itemList = [itemId];
    console.log('Logged itemList:', itemList);
    const response = await this.fetchData(itemList);
    // Further code execution
  }
},

However, when the itemList variable is passed to FETCH_DATA, it becomes undefined. Here’s the output from the console logs:

Logged itemList: [123456]
Received itemList in FETCH_DATA: undefined

I’ve tried checking the scope, ensuring proper variable passing, and debugging with console.log statements, but I can’t seem to figure out why itemList is becoming undefined in the FETCH_DATA function.

Node js cannot load module

I know this is a common problem. I tried reinstall npm, delete node_modules files and package-lock.json. But still it didn’t work. Here is my console result:

node:internal/modules/cjs/loader:1080
throw err;
^

Error: Cannot find module 'config.json'
Require stack:

- /Users/phoebe/Downloads/Zips/idiot_bot_js/index.js
  at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
  at Module._load (node:internal/modules/cjs/loader:922:27)
  at Module.require (node:internal/modules/cjs/loader:1143:19)
  at require (node:internal/modules/cjs/helpers:119:18)
  at Object.<anonymous> (/Users/phoebe/Downloads/Zips/idiot_bot_js/index.js:7:17)
  at Module._compile (node:internal/modules/cjs/loader:1256:14)
  at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
  at Module.load (node:internal/modules/cjs/loader:1119:32)
  at Module._load (node:internal/modules/cjs/loader:960:12)
  at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/phoebe/Downloads/Zips/idiot_bot_js/index.js' ]
  }

Node.js v18.18.0

Here is my code file structure (I do have config.json in the same folder as index.js)

> ls
commands     data    hook    index.js  node_modules       package.json  utils
config.json  events  images  LICENSE   package-lock.json  README.md

Here is my index.js

'use strict';

const { Client, GatewayIntentBits } = require('discord.js');
const { readdirSync } = require('fs');
const { join } = require('path');

const { bot } = require('config.json');
const CmdList = require('./utils/CmdList.js');

const { log } = require('./utils/Log.js');
const deployCmd = require('./utils/deployCmds.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.events = readdirSync(join(__dirname, './events'));
for (let event of client.events) {
    if (event.indexOf('Base') !== -1 || event.indexOf('.json') !== -1) {
        continue;
    }

    const eventModule = require(`./events/${event}`);
    if (typeof eventModule !== 'function') {
        log.write('skip bad event:', event);
        continue;
    }

    const eventClass = new eventModule();
    client.on(eventClass.name, (...args) => {
        eventClass.eventCallback(client, ...args)
            .catch( (err) => {
                log.write(eventClass.name, 'catch error:', err);
                client.errHandler.send(err);
            });
    });

    log.write('installed event:', eventClass.name);

}

client.cmdList = new CmdList();
const commands = readdirSync(join(__dirname, './commands'));
for (let cmd of commands) {
    if (cmd.indexOf('Base') !== -1  || cmd.indexOf('.json') !== -1) {
        continue;
    }

    const cmdModule = require(`./commands/${cmd}`);
    if (typeof cmdModule !== 'function') {
        log.write('skip bad command:',  cmd);
        continue;
    }

    const cmdClass = new cmdModule();
    client.cmdList.installCmd(cmdClass);
}

deployCmd(client.cmdList.cmdsBuilder.map(command => command.toJSON()));

client.login(bot.token);

Here is my config.json

{
    "bot": {
        "token": "MTIwNzk0MTc0NjkxOTc0MzQ4OA.GnreJ7.UHciMfVU6k2AaJ_" (changed a few characters for security)
    }
}

Thank you so much for the help!

tried reinstall npm, delete node_modules files and package-lock.json.

Javascript is not being executed on Chrome Windows 11

I’m struggling with the issue that inline Javascript isn’t being executed on this page using Google Chrome on Windows 11 (121.0.6167.161).

Javascript code isn’t recognized at all as the console shows a warning

Uncaught ReferenceError: adPixfuture is not defined

The function adPixfuture is defined in the inline JS code.

Breakpoints at the very first line of each <script>-tag are not being hit.

Javascript is activated. On other sites Javascript is normally executed.

I assume the JS code is basically without errors as on MacOS and iOS (both Chrome and Safari) everythings works fine.

What am I missing? Whats the reason that inline JS code is not being recognized at all?

Nest.js optional parameter

I found out a little problem in my nest.js.

I have this function call and the first one is not working and the second one is good. The problem is with ip. I am calling this function from many places. My tsconfig has everything turned on true and didn’t mention that it is a problem.

Why? Can somebody explain, please?

  async updateUser(
    userId: string,
    dto: myDto,
    ip?: string,
    isRegistration: boolean = false
  ): Promise<boolean> {}
  async updateUser(
    userId: string,
    dto: myDto,
    ip: string | null = null,
    isRegistration: boolean = false
  ): Promise<boolean> {}

The architecture behind new whatsapp web

Just curious about the architecture behind the new whatsapp web,
how the new whatsapp web can keep syncronize with new incoming message even when my phone is offline?
does whatsapp store user’s message in their server now ?

I want to know how the new architecture work, where whatsapp store all the incoming message when primary and linked devices is offline?

How to fetch a csv file from github organization programmatically?

I need to know how can I implement code in my repo that can fetch/read csv files from another repo?
Both these repositories are present in same private organization. I tried to implement like this using personal access token but it doesn’t work in github enterprise.

.file = (await fetch(
https://api.github.com/repos/${OWNER}/${REPO}/contents/${PATH},
{
headers: {
authorization: token ${Secret("GITHUB_ACCESS_TOKEN")},
accept: “application/vnd.github.v3+json”
}
}
)).json()

Main goal is every time I run repo A is should fetch file from repo B and read the data.
Thanks in advance.

Calculation in HTML

I have a code that should calculate the ‘net = gross – bir,’ ‘currentBcaTotalBalance -= net,’ or ‘receipts + current bca total/balance = new bca total/balance.’ The issue is that it doesn’t calculate ‘receipts + current bca total/balance = new bca total/balance’ correctly. Similar to what happened in the picture. When I input receipts of 100, the result is 600 instead of the expected 700. (https://i.stack.imgur.com/e2rxJ.png)

Here is my code for function addData

let currentBcaTotalBalance = 0;


         function addData() {
            // Get input values
            let dv = document.getElementById("dvInput").value;
            let date = document.getElementById("dateInput").value;
            let number = document.getElementById("numberInput").value;
            let check = document.getElementById("checkInput").value;
            let payee = document.getElementById("payeeInput").value;
            let uacs = document.getElementById("uacsInput").value;
            let particulars = document.getElementById("particularsInput").value;
            let project = document.getElementById("projectInput").value;
            let period = document.getElementById("periodInput").value;
            let gross = formatAmountInput(document.getElementById("grossInput").value) || 0;
            let bir = formatAmountInput(document.getElementById("birInput").value) || 0;
            let net = formatAmountInput(document.getElementById("netInput").value) || 0;
            let receipts = formatAmountInput(document.getElementById("receiptsInput").value) || 0;
            let total = formatAmountInput(document.getElementById("totalInput").value) || 0;

            // If it's the first entry, set the current BCA Total/Balance to 0
            if (currentBcaTotalBalance === 0) {
                currentBcaTotalBalance = total;
            }

            // Calculate net amount
            net = gross - bir;

            // Subtract Gross from the current BCA Total/Balance
            currentBcaTotalBalance -= net;

            // Calculate new BCA total/balance
            let newBcaTotalBalance = net + receipts;

            // Format numbers with commas
            let formattedGross = formatAmount(gross);
            let formattedBIR = formatAmount(bir);
            let formattedNet = formatAmount(net);
            let formattedReceipts = formatAmount(receipts);
            let formattedTotal = formatAmount(currentBcaTotalBalance);

            // Get the table and insert a new row at the end
            let table = document.getElementById("outputTable");
            let newRow = table.insertRow(table.rows.length);

            // Insert data into cells of the new row
            newRow.insertCell(0).innerHTML = dv;
            newRow.insertCell(1).innerHTML = date;
            newRow.insertCell(2).innerHTML = number;
            newRow.insertCell(3).innerHTML = check;
            newRow.insertCell(4).innerHTML = payee;
            newRow.insertCell(5).innerHTML = uacs;
            newRow.insertCell(6).innerHTML = particulars;
            newRow.insertCell(7).innerHTML = project;
            newRow.insertCell(8).innerHTML = period;
            newRow.insertCell(9).innerHTML = formattedGross;
            newRow.insertCell(10).innerHTML = formattedBIR;
            newRow.insertCell(11).innerHTML = formattedNet;
            newRow.insertCell(12).innerHTML = formattedReceipts;
            newRow.insertCell(13).innerHTML = formattedTotal;
            newRow.insertCell(14).innerHTML =
                '<button onclick="editData(this)">Edit</button>' +
                '<button onclick="deleteData(this)">Delete</button>';

            // Clear input fields
            clearInputs();
        }

How to integrate object items in array convert to a table

Could you please give me suggestion to solve this problem?

i got a datas like:

 orders =[
        {
            orderID:1,
            Name: 'Sam',
            orderList: [
                {SKU: 'A001',Qty: 2},{SKU: 'A003',Qty: 4}
            ]
        },
        {
            orderID:2,
            Name: 'Sam',
            orderList: [
                {SKU: 'A001',Qty: 1},{SKU: 'A002',Qty: 1}
            ]
        },
        {
            orderID:3,
            Name: 'Sam',
            orderList: [
                {SKU: 'A001',Qty: 2},{SKU: 'A004',Qty: 2}
            ]
        },
        {
            orderID:4,
            Name: 'Sam',
            orderList: [
                {SKU: 'A003',Qty: 3},{SKU: 'A002',Qty: 1}
            ]
        },
        {
            orderID:5,
            Name: 'Sam',
            orderList: [
                {SKU: 'A002',Qty: 1},{SKU: 'A003',Qty: 1}
            ]
        }
]

//after foreach i want to output each order items and gather their SKU and qty like:

foreach ($orders as $order) {
   echo <td>$order.orderList.sku</td>
   echo <td>$order.orderList.qty</td>
   
//output a table like:
/*
item     |    Qty
A001     |    5
A002     |    4
A003     |    8
A004     |    2
B001     |    1
/*
}

Please give me some suggestion, thank you so much!

while printing data from datatable as pdf, I want to get seperate pdf according to similar column values in CodeIgniter 3

I have many doctor name in a column. While printing table data as pdf, I want separate pdf for each doctor. I am doing this project on CodeIgniter 3. I am using window.print() for printing data from data table as pdf.

I have many doctor name in a column. While printing table data as pdf, I want separate pdf for each doctor in CodeIgniter 3 by using window.print() for printing data from data table as pdf.

Fullcalender is not loaded but loaded on clicking on inspect, ctrl + or ctrl-

I’ve integrated the fullcalender plugin version 6.1.10 in a web application from https://fullcalendar.io/. This application is built with Laravel 10. But the fullcalender is not loaded but rather clicking on inspect or ctrl + or ctrl -. I’ve understood the fullcalender is loaded if the window size of the page is changed. Can anyone please help me?

enter image description here

enter image description here

I’ve written the following code in blade file

<div class="tab-pane fade " id="v-pills-calendar" role="tabpanel" aria-labelledby="v-pills-calendar-tab">
<!-- Your content for the Bank tab goes here -->
<div class="content">
    <div class="teacherProfile-tab-five">
        <div class="teacher-heading">
            <h1>Calendar</h1>
        </div>
        <div class="calender-content">
            <div class="schedule-button">
                <a href="{{ route('tutor.schedule_lesson') }}"><button type="button" class="btn btn-secondary d-flex">
                        <p>Schedule a lesson</p>
                        <img src="{{ asset('webapp/assets/images/icons/carbon_add-filled.svg') }}" class="button-icon" loading="lazy" alt="add" />
                    </button></a>
            </div>

            <!-- <div id="calendar-container"></div> -->
            <div id="calendar"></div>
            <div class="calendar-check-boxes d-flex">
                <div class="calendar-cb-one me-5">
                    <input class="form-check-input" type="checkbox" value="" id="onlineCheckbox" />
                    <label class="form-check-label" for="onlineCheckbox">
                        Online
                    </label>
                </div>
                <div class="calendar-cb-two">
                    <input class="form-check-input" type="checkbox" value="" id="inPersonCheckbox" />
                    <label class="form-check-label" for="inPersonCheckbox">
                        In person
                    </label>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
    let calendarEl = document.getElementById('calendar');

    let calendar = new FullCalendar.Calendar(calendarEl, {
        initialView: 'dayGridMonth',
        initialDate: "{{ date('Y-m-d') }}",
        themeSystem: "bootstrap",
        headerToolbar: {
            left: 'prev,next today',
            center: 'title',
            right: 'dayGridMonth,timeGridWeek,timeGridDay'
        },
        events: [{
                title: 'All Day Event',
                start: '2024-02-01'
            },
            {
                title: 'Long Event',
                start: '2021-02-07',
                end: '2024-02-10'
            },
            {
                groupId: '999',
                title: 'Repeating Event',
                start: '2024-02-09T16:00:00'
            },
            {
                groupId: '999',
                title: 'Repeating Event',
                start: '2024-02-16T16:00:00'
            },
            {
                title: 'Conference',
                start: '2024-02-11',
                end: '2024-02-13'
            },
            {
                title: 'Meeting',
                start: '2021-04-12T10:30:00',
                end: '2021-04-12T12:30:00'
            },
            {
                title: 'Lunch',
                start: '2021-04-12T12:00:00'
            },
            {
                title: 'Meeting',
                start: '2021-04-12T14:30:00'
            },
            {
                title: 'Birthday Party',
                start: '2021-04-13T07:00:00'
            },
            {
                title: 'Click for Google',
                url: 'http://google.com/',
                start: '2024-02-24'
            }
        ]
    });

    calendar.render();

});

Scorm Content showing Error initializing communications with LMS

`I use ‘scorm-again’ javascript library in my angular 16 application to display SCORM content. SCORM API initialized successfully then I am getting an error: DisplayError, strMessage=Error initializing communications with LMS. My LMS running in localhost. always SCORM content showing in a popup window. but I am using and it should display in a parent template. rather then popup window.

// scorm.component.ts

import { Component, OnInit } from '@angular/core';
declare var Scorm12API;

declare global {
  interface Window {
    API: typeof Scorm12API; 
  }
}

@Component({
  selector: 'app-scorm-again-player',
  templateUrl: './scorm-again-player.component.html',
  styleUrls: ['./scorm-again-player.component.scss']
})
export class ScormAgainPlayerComponent implements OnInit {
  externalUrl:string = "assets/scorm/dummy_scorm/dummy_scorm/scormdriver/indexAPI.html";  

  constructor() {}

  ngOnInit() {
    const settings={commitUrl:'http://localhost:4200'}
    
    window.API = new Scorm12API(settings);
    window.API.LMSInitialize();
  }

}

// scorm.component.html

<iframe [src]="externalUrl | safe" height="600" width="1000" title="" id="scormIframe"></iframe>

SCORM API initialized successfully and it’s showing error to play SCORM content.

enter image description here`

Intelij Grails gradle projects

I wrote Grails project in intelij all functionalities working fine in local but in production getting modal is not a function error please anyone help me to resolve this issue.

I tried to add new versions of jQuery and bootstrap but that modal is not working .after clicking the Create operator button popup window has to be appear in local all functionalities are working fine after deployment tha one functionality not working .