Forwarding a request from Nodejs

I need to forward / redirect request received by nodejs endpoint to a .net 7 web API end point. Nodejs endpoint is triggered by an external party and it receives the request as expected. the problem is redirecting / forwarding from nodejs to .NET web api endpoint, its not getting triggered.

This is my code block.

exports.rerouteIncomingEmail = async (req, res)  => {

var to = extractRequestHeaders(req.headers, 'x-recipient');
var endPoint = await services.getPushEndpointFromEmailList(to,req.app.locals.db);

endPoint ? res.redirect(308,endPoint) : res.send(200,'endpoint not found');    

};

How I can make website like codewithharry

How I can make website like codewithharry

I want to create website like codewithharry design is ready but need BACKEND

Can anyone help. Me to create it

Or any steps or tutorials or any tutorial which have tell or make website back-end like him plz answer…………..,..,…,..,,.,,.,..,.,………

I want to create website like codewithharry design is ready but need BACKEND

Can anyone help. Me to create it

Or any steps or tutorials or any tutorial which have tell or make website back-end like him plz answer…………..,..,…,..,,.,,.,..,.,………

DiscordJS v14 – How to check if bot is already connected to a voice channel?

So I have a problem that when I use interaction.member.guild.voiceStates.cache.get('BOT_ID') it doesn’t update when the bot is already disconnected or being moved.

const getVoice = interaction.member.guild.voiceStates.cache;
const botVoiceChannel = getVoice.get('BOT_ID');

if (botVoiceChannel) {
  errEmbed = new EmbedBuilder()
  .setDescription("I'm already connected to a voice channel")
  return interaction.reply({ embeds: [ errEmbed ] });
}

I expect the value of botVoiceChannel to change to a new voice channel or null when the bot is being moved or disconnected.

lingui library’s macro t not working on react

i use the this latest library for translate, but the macro t not working, the <Trans> working fine.

To Reproduce

  1. open codesandbox
  2. yarn install
  3. yarn start
  4. click different language on the top of screen

bug description:
only content in <Trans> content </Trans> will translated, but the last content on {t`hello react`} not translated.

index.tsx:

import React from 'react';
import ReactDOM from 'react-dom/client';
import reportWebVitals from './reportWebVitals';
import { StoreProvider } from './components/store-provider';
import createStore from './store'
import { LanguageProvider } from './components/language-provider';
import { LangSwitcher } from './components/lang-switcher';
import { Trans, t } from '@lingui/macro';

const store = createStore();

const root = ReactDOM.createRoot(
    document.getElementById('root') as HTMLElement
);
root.render(
    <React.StrictMode>
        <StoreProvider store={store}>
            <LanguageProvider>
                <LangSwitcher />
                <p>
                    <Trans>hello world</Trans>
                </p>
                <p>{t`hello react`}</p>
            </LanguageProvider>
        </StoreProvider>
    </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. 
reportWebVitals();

package.json:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@lingui/react": "^4.1.2",
    "@reduxjs/toolkit": "^1.9.5",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^13.0.0",
    "@testing-library/user-event": "^13.2.1",
    "@types/jest": "^27.0.1",
    "@types/node": "^16.7.13",
    "@types/react": "^18.0.0",
    "@types/react-dom": "^18.0.0",
    "make-plural": "^7.3.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-redux": "^8.0.5",
    "react-scripts": "5.0.1",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.2.3",
    "typescript": "^4.4.2",
    "web-vitals": "^2.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
        "extract": "lingui extract --clean",
    "compile": "lingui compile --strict"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@lingui/cli": "^4.1.2",
    "@lingui/macro": "^4.1.2"
  }
}

lingui.config.ts:

const linguiConfig = {
  catalogs: [
    {
      path: '<rootDir>/src/locales/{locale}/messages',
      include: ['<rootDir>/src'],
    },
  ],
  compileNamespace: 'cjs',
  fallbackLocales: {
    default: 'en-US',
  },
  format: 'po',
  formatOptions: {
    lineNumbers: false,
  },
  locales: [
    'en-US',
    'zh-CN',
    'zh-TW',
  ],
  orderBy: 'messageId',
  rootDir: '.',
  runtimeConfigModule: ['@lingui/core', 'i18n'],
  sourceLocale: 'en-US',
  pseudoLocale: 'pseudo',
}

export default linguiConfig

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
        "baseUrl": "src"
  },
  "include": [
    "src"
  ]
}

Why does FusionAuth’s MFA redirect me to login credentials and asks for my PC password?

when I click fusion auth’s account->MFA I was auto redirect to another window and ask me about logging credentials but when I entered them and logged in they ask my pc password and pop up some messages from windows security I accidently close them. If anyone faced this situation please help me. explain about this situation.
thank you!

I created another account and do same process go to account->MFA but not faced recent situation

Notion api send plain text

I am trying to send some simple text to notion page.there is nothing wrong with the Notion key or page id. I am able to successfully send and retrieve data into databases but i am not able to work with the simple pages.

I thought the notion api is only to use to manipulate the databases but after reading the documentation there is some things about blocks and pages where i can send data to pages.

const Client = require("@notionhq/client").Client;
// const dotenv = require("dotenv");
//
// dotenv.config();
//
// const NOTION_CLIENT = new Client({ auth: process.env.NOTION_KEY });
// const DATABASE_ID = process.env.NOTION_DATABASE_ID;
// const PAGE_ID = process.env.NOTION_PAGE_ID;

const NOTION_TOKEN = "";
const PAGE_ID = "";

async function sendPlainTextToNotion(content) {
  const url = `https:api.notion.com/v1/blocks/${PAGE_ID}/children`;
  const headers = {
    Authorization: `Bearer ${NOTION_TOKEN}`,
    "Content-Type": "application/json",
    "Notion-Version": "2022-06-28",
  };

  const requestBody = {
    children: [
      {
        object: "block",
        type: "paragraph",
        paragraph: {
          text: [
            {
              type: "text",
              text: {
                content: content,
              },
            },
          ],
        },
      },
    ],
  };

  try {
    const response = await fetch(url, {
      method: "POST",
      headers: headers,
      body: JSON.stringify(requestBody),
    });

    if (!response.ok) {
      throw new Error("Error sending plain text to notion");
    }
    if (response.ok) {
      console.log("Plain text sent to notion successfully");
    }
  } catch (error) {
    console.log(error);
  }
}

const textContent = "this is a plaint content example";

sendPlainTextToNotion(textContent);

Discord Reload Command gives me a Error and i dont know why?

Hi why the reload command not working it says me the error and i dont know why.

If i Reload a command and i try the command again after reload it says the error.

Reload Command:

const Discord = require('discord.js')

const Command = require('../../structures/CommandClass');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v10');
const fs = require('fs');
require('dotenv').config();

const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');


  

module.exports = class reload extends Command {
    constructor(client) {
        super(client, {
            data: new SlashCommandBuilder()
                .setName('reload')
                .setDescription('Command Reloader')
        .addStringOption(option =>
          option.setName('command')
            .setDescription('The command to reload.')
            .setRequired(true)),     
        });
    }
      
    async run(client, interaction) {
    const commandName = interaction.options.getString('command', true).toLowerCase();
        const command = interaction.client.commands.get(commandName);

        if (!command) {
            return interaction.reply(`There is no command with name `${commandName}`!`);
        }
        
    delete require.cache[require.resolve(`./${command.name}.js`)];

    try {
      interaction.client.commands.delete(command.name);
      const newCommand = require(`./${command.name}.js`);
      interaction.client.commands.set(newCommand.name, newCommand);
      await interaction.reply(`Command `${newCommand.name}` was reloaded!`);
    } catch (error) {
      console.error(error);
      await interaction.reply(`There was an error while reloading a command `${command.name}`:n`${error.message}``);
    }


    

    }

 
}

Clear Command:

const { SlashCommandBuilder } = require('discord.js');
const Command = require('../../structures/CommandClass');
const { PermissionFlagsBits } = require('discord.js');

module.exports = class clear extends Command {
    constructor(client) {
        super(client, {
            data: new SlashCommandBuilder()
                .setName('clear')
                .setDescription('Lösche beliebig viele Nachrichten (Nachrichten älter als 14 Tage können nicht gelöscht werden)')
                .addNumberOption(option => option.setName('anzahl').setDescription('Die Anzahl der Nachrichten').setRequired(true).setMaxValue(100).setMinValue(1))
                .setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
                .setDMPermission(false),
        });
    }

    async run(client, interaction) {
      const amount = interaction.options.getNumber('anzahl');

      let log = interaction.guild.channels.cache.get('1052539647575736362');
      let staff = await interaction.member.fetch();
      
    
        
try {
        await interaction.channel.bulkDelete(amount, true).catch(err => {
          console.error(err);
          interaction.reply('FEHLER beim Narichten löschen aufgetreten!');
      });

      log.send(`**`${staff.user.tag}`** **hat ${amount} Nachrichten gelöscht! Für mehr Infos siehe Audit-log.**`);
      return await interaction.reply({ content: `${amount} Nachrichte Gelöscht!`, ephemeral: true });
    } catch (error) {
      console.log(error);
      interaction.reply({
        content: '**Fehler beim Löschen der Nachrichten aufgetreten, `/report` um denn Bug zu melden!**',
        ephemeral: true,
      });
    };    
        
    
    

    }
};

command class:

module.exports = class Command {
    constructor(client, meta = {}) {
        this.client = client;
        this.data = meta.data;
        this.contextDescription = meta.contextDescription || null;
        this.usage = meta.usage || this.name;
        this.category = meta.category || 'Info';
        this.permissions = meta.permissions || ['Use Application Commands', 'Send Messages', 'Embed Links'];
    }

    async run() {
        throw new Error(`The Slash Command "${this.name}" does not provide a run method.`);
    }
};

Interaction Create:

const Event = require('../../structures/EventClass');

const { InteractionType, ComponentType } = require('discord.js');

const defaultAutoComplete = require('../../assets/json/autocomplete.json');

module.exports = class InteractionCreate extends Event {
    constructor(client) {
        super(client, {
            name: 'interactionCreate',
            category: 'interactions',
        });
    }
    async run(interaction) {
        const client = this.client;
        const command = client.commands.get(interaction.commandName);
        
        if (interaction.type === InteractionType.ApplicationCommand) {
            
            
            if (interaction.user.bot) return;
            if (!interaction.inGuild() && interaction.type === InteractionType.ApplicationCommand) return interaction.reply({ content: 'Du musst dich auf einem Server befinden um diesen Command zu benutzen!' });

            if (!command) return interaction.reply({ content: '**Command zurzeit nicht verfügbar!**', ephemeral: true }) && client.commands.delete(interaction.commandName);

            try {
                command.run(client, interaction);
            }
            catch (e) {
                console.log(e);
                return interaction.reply({ content: `An error has occurred.nn**`${e.message}`**` });
            }
        }

        if (interaction.type === InteractionType.ModalSubmit) {
            if (interaction.customId === 'prefixForm') {
                const prefix = interaction.fields.getTextInputValue('prefix');
                const reason = interaction.fields.getTextInputValue('reason');

                return await interaction.reply({ content: `Prefix has been set to: **`${prefix}`**n**Reason:** ${reason}` });
            }
        }

        if (interaction.type === InteractionType.ApplicationCommandAutocomplete) {
            const focused = interaction.options.getFocused().toLowerCase();
            let filter;

            switch (interaction.commandName) {
            case 'autocomplete':
                filter = defaultAutoComplete.filter(option => option.value.toLowerCase().startsWith(focused));
                await interaction.respond(filter);
                break;
            }
        }

        
        
    }
};

Error:

TypeError: command.run is not a function
    at InteractionCreate.run (C:UsersAdministratorDesktopwtdeutsch-maineventsguildinteractionCreate.js:27:13)
    at BotClient.emit (node:events:525:35)
    at InteractionCreateAction.handle (C:UsersAdministratorDesktopwtdeutsch-mainnode_modulesdiscord.jssrcclientactionsInteractionCreate.js:97:12)
    at module.exports [as INTERACTION_CREATE] (C:UsersAdministratorDesktopwtdeutsch-mainnode_modulesdiscord.jssrcclientwebsockethandlersINTERACTION_CREATE.js:4:36)
    at WebSocketManager.handlePacket (C:UsersAdministratorDesktopwtdeutsch-mainnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:352:31)
    at WebSocketShard.onPacket (C:UsersAdministratorDesktopwtdeutsch-mainnode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:494:22)
    at WebSocketShard.onMessage (C:UsersAdministratorDesktopwtdeutsch-mainnode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:328:10)
    at callListener (C:UsersAdministratorDesktopwtdeutsch-mainnode_moduleswslibevent-target.js:290:14)
    at WebSocket.onMessage (C:UsersAdministratorDesktopwtdeutsch-mainnode_moduleswslibevent-target.js:209:9)
    at WebSocket.emit (node:events:513:28)

I dont know if the Reload Command code false or in the interaction create file. I need realy help because i realy dont unterstand why the error is comming

Seemingly can’t use new libraries in react native

I’ve been trying to make use of numerous libraries for my react native project for android, but none seem to be working. As an example, I tried to import and use the “@react-native-async-storage/async-storage” library. It installs fine and shows up in my dependencies, but an attempt to use it results in the error “NativeModule: AsyncStorage is null.”

I get this or similar errors every time I try to use a new library. I really am clueless here, so any help is appreciated.

To clarify, this is a issue that seemingly just manifested out of nowhere. Up until now, I have had zero issue importing and using libraries, and my project is currently using multiple libraries without issue.

I tried resetting the cache and rebuilding the project as recommended, but as far as I can tell, these steps have changed nothing.

sudden stop of a loop in javaScript [closed]

function game() {

    let points = 0;
    const maxPoints = 20;
    const maxTime_min = 2;
    const maxTime_sec = 30;

    var seg = 0;
    var min = 0;
    var isPause = false;

    function doisDigitos(digito) {
        if (digito < 10) {
            return ('0' + digito);
        } else {
            return (digito);
        }
    }
    
    function tempo() {
        setInterval(aContar,1000);
    }
    
    function aContar() {
        if (!isPause) {
            seg++;
            if(seg == 60) {
                min++;
                seg = 0
            }
            document.getElementsByClassName('tempo')[0].innerText = doisDigitos(min) + ':' + doisDigitos(seg);
        }
    }    

    window.addEventListener('load', tempo());

    function game_State() {

        
        checkVictoryHorizontal();
        checkVictoryVertical();       

        if (min < maxTime_min && seg < maxTime_sec)
        {
            setTimeout(game_State, 100);
        }
        if (min == maxTime_min && seg >= maxTime_sec)
        {
            isPause = true;
            console.log('dead game');
        }
    }

    game_State();
}

The first three functions have the objective of creating a stopwatch, the game_State function serves to activate the two functions checkVictoryHorizontal and checkVictoryVertical every 100 milliseconds, that is, if the variable seg and min do not reach their respective maximum data by the constants maxTime_seg and maxTime_min, the two conditions The purpose of the following is to check the state of the two variables in relation to their maximums, but the problem is that whenever the variable seg reaches values greater than 30, the gameState function is no longer activated even if the maximum time, which in this case would be 2 minutes and 30 seconds has not passed

Vignette ads applying to form submit button

I’ve noticed that google adsense vignette ads are performing well on my site, but they do not appear when the primary function is performed- notably the clicking of a form submit button.

I can’t find any reference in google’s documentation about what specific links the ads will attach to, but using the debugger it seems to work on hard links on the page, which includes links on images.

Is there any known way to make these work on form submit buttons, or a good workaround that will enable them- such as using an href link that then submits the form via script?

Here is an example:
https://lagged.com/en/g/elastic-man

Every time you press “Play Now” comes the call of this advertisement.

Petite-Vue on-click missing in compiled html, and “not defined” for reactive properties in app

I am trying to create a “fake” multi-page website by toggling div visibility using v-if. However I am running into two issues:

First <a href="#" v-on:click="toggleText">click to toggle</a> is being compiled to <a href="#">click to toggle</a>. Same when using div instead of a href, and then it can not be clicked.

Secondly, even if I switch the div to a button I keep getting an error “showText is not defined”, but I define ShowText as a reactive property in the app object?

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Petite-Vue Example</title>
  <style>
    .hidden-text {
      display: none;
    }
  </style>
</head>
<body>
  <div id="app">
    <button class="clickable" @click="toggleText">Click me!</button>
    <div v-if="showText" class="hidden-text">Hidden text revealed!</div>
  </div>

  <script type="module">
    import { createApp } from 'https://unpkg.com/[email protected]/dist/petite-vue.es.js?module'
    const app = {
      showText: false,
      toggleText() {
        this.showText = !this.showText;
      }
    };

    createApp({
      data() {
        return app;
      },
      methods: {
        toggleText: app.toggleText
      }
    }).mount('#app');
  </script>
</body>
</html>

Any pointers would be appreciated!

Updating x-data with Alpine.js in JavaScript’s init function

Alpine.js: How do we update an x-data=”{ ShowReport: false }” in an init function of Javascript?

I’m trying to open a <div> once a file already executed(which is now good) but the ShowReport didn’t change to “true”

Trying to update the ShowReport to “true” Please see the attached code:

div class="mt-2" x-data="{ ShowReport: false }">
            <button class="dui-btn dui-btn-neutral" x-on:click="ShowReport = ! ShowReport">Show Report</button>
            <div x-show="ShowReport">
                <div class="p-4">
                    <div id="csv-response"></div>
                </div>
            </div>
        </div>

 <script>
        document.addEventListener("DOMContentLoaded", () => {
            const csvUploadDropzone = new common.Dropzone("#csv-upload-dropzone", {
                dictDefaultMessage: "Drag and drop your csv here",
                url: "{% url 'buyer:csv-upload' buyer.id %}",
                acceptedFiles: '.csv',
                uploadMultiple: false, // POST a single document at a time (on server URL ``url``)
                autoProcessQueue: true, // true will trigger automatic uploading/processing of the dropped resume
                maxFiles: 1, // a maximum of a single CV
                dictMaxFilesExceeded: "You may only upload a single csv document!",
                maxFilesize: 10, // in MB
                addRemoveLinks: true,
                dictRemoveFile: "Remove",

                init: function () {
                    this.on("success", function (file, response) {
                        // Updates the "hidden" csv with whatever the server sent back to us...
                        document.getElementById('csv_filename').value = response['csv_filename'];
                        document.getElementById("csv-response").innerHTML = response;
                        this.ShowReport = true
                    });
                },

                //success: function(file, response) {
                    // Updates the "hidden" csv with whatever the server sent back to us...
                    //document.getElementById('csv_filename').value = response['request_file'];
                    //console.log(file)
                //},

                removedfile: function(file) {
                    // Update our hidden filename; then call the "default" behaviour as per docs...
                    document.getElementById('csv_filename').value = null;

                    if (file.previewElement != null && file.previewElement.parentNode != null) {
                        file.previewElement.parentNode.removeChild(file.previewElement);
                    }
                    return this._updateMaxFilesReachedClass();
                },

                maxfilesexceeded: function(file) {
                    alert("You may only upload a single csv document!");
                    this.removeFile(file);
                },

            });
        });
        
    </script>

How to pass a JS variable as a parameter to a Python function and store Python output as a JS variable?

I’m trying to get my html+JS file to communicate with my python file, but I’m stuck on how to take a variable from the JS, use it as a parameter in a python function, and then store the python’s output as a JS variable. I’m not able to provide my actual implementation, but here is a skeleton of what I’m trying to do:

app.py

def foo(input):
    #lots of computation
    return result

index.html

<link rel="stylesheet" href="fonts.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<p>Type here: <span id="field"></span></p>
<script>
var fieldSpan = document.getElementById('field');

var inputData= fieldSpan.textContent;

var outputData = /* Something that essentially calls the function foo(inputData) and returns its output*/
</script>

I don’t have very much experience with JQuery or NodeJS, but I’ve come across some things saying to use flask(?) and ajax(??) to get the JS and python to talk to each other. Any help on that front would be really helpful.

Now, what I was able to get working was to use nodeJS to communicate with my python file. Here’s what the JS looks like:
test.js

const spawner = require('child_process').spawn;

//string
const data_in = 'Send this to python script.';

console.log('Data sent to python script: ', data_in);
const python_process = spawner('python', ['./app.py',data_in]);

python_process.stdout.on('data',(data) => {
    console.log('Data received from python script:', data.toString());
});

(credit to Apes in Capes)

running node test.js returns exactly what I want, but I’m not sure how to integrate this into the html textbox, so that the data_in can be equal to the user’s input. So if instead of using the whole flask/ajax system, it’s possible to use nodeJS, that’d be fantastic, but in either case, I just need to figure out how to get the files communicating. Thanks!

to get a popup box with a link on submit click

I’d appreciate a lot if someone could help me to solve a simple problem.I am trying to get a popup box with a application accepted message and a link to home page on submit button click, but only after validation .popup box is not coming on button click

now i want a popup box on submit button.But pop up window doesn’t appear when clicked on button. What did I miss or do wrong? Thanks in advance,also am new to here…

This is the part i have to show when submit button click  


 <h2>Application Accepted</h2>
    <span class="close">&times;</span>
</div>
<div class="modal-body">
  <p>Go Back To Home Page  <a href="home">Home</a></p>
</div>
</div>
i have to validate every feild only after i want that popup box
form:-

<form method='post' name='f1'>
<h2 style="padding-left:50px">Application Form</h2>
<table>
    <tr>
        <td>
            <label for="uname">Name</label>
        </td>
        <td>
            <input type="text" id="uname" name="username" required>
        </td>
    </tr>
    <tr>
        <td>
            <label for="date">Date Of Birth</label>
        </td>
        <td>
        <input type="date" id="date" name="date" required>            </td>
    </tr>


     
      <tr>
        <td>
            <label>Gender</label>
        </td>
        <td>
            <label>
                <input type="radio" value="female" name="gender" required> Female</label>
                <label>
                <input value="male" type="radio" name="gender"> Male</label>
        </td>
    </tr>
   <tr>
        <td></td>
        <td>


            

    <button type="submit" id="myBtn"   onclick="return valid()">SUBMIT</button>
    

  
        </td>
    </tr>
</table>
</form>

validation part:

<script type=”text/javascript”>

function valid()
{

    if(f1.username.value=="")
    {
        alert('enter the name');
        f1.username.focus();
        return false;
    }
    

    else if(f1.date.value=="")
    {
        alert('enter your date of birth');
        f1.date.focus();
        return false;
    }
    
    else if(f1.gender.value=="")
    {
        alert('Select gender');
        f1.gender.focus();
        return false;
    }
    
    
    

    else
     {
        var modal = document.getElementById("myModal");
        var btn = document.getElementById("myBtn");
        var span = document.getElementsByClassName("close")[0];


        btn.onclick = function() {
          modal.style.display = "block";
        }

        span.onclick = function() {
          modal.style.display = "none";
        }


        window.onclick = function(event) {
          if (event.target == modal) {
            modal.style.display = "none";
          }
        }

     }
}

</script>

`

Can’t get my current time using new Date()

At the time of running this code, my time was 10:47 AM PST. But this code returned 2023-5-19 17:45:56, so it is 7 hours ahead for some reason. I checked my PC settings and the time zone is correct. I cannot get my actual current time. What gives?

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;
 
console.log(dateTime)