How do I collect information from all users on a website and store it on the server side [closed]

I am making a small web game along the lines of wordle or guess the game, etc, and I want to get every users score (number of guesses) of the day so that I can keep a global average to display to the players.

I’m new to web development so I am just learning as I go, and it’s not hosted anywhere yet, I’m just doing it locally for development at the moment, I’m not sure if that affects what I can do right now.

GET http://127.0.0.1:5500/dataFood 404 (Not Found) trying to print my sql data into my html

my problem is im trying to connect to mysql and im using express.js server and the problem is this GET http://127.0.0.1:5500/dataFood 404 (Not Found) .
I have 2 codes the client side and the server side ill print everthing here to see what is the problem.

**server side code in javascript:
**

const mysql = require('mysql');
const express = require('express');
const app = express();

// MySQL database connection configuration
const connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'rootuser',
    database: 'foodDatabase',
    port: 3306
});

// Connect to the MySQL database
connection.connect((err) => {
    if (err) {
        console.error('Error connecting to MySQL database:', err.stack);
        return;
    }
    console.log('Connected to MySQL database as ID ' + connection.threadId);
});

// Serve static files (HTML, CSS, JavaScript)
app.use(express.static('public'));


// Route to fetch data from the database
app.get('/dataFood', (req, res) => {
    // Perform a query to fetch data
    connection.query('SELECT * FROM meals', (error, results, fields) => {
        if (error) {
            console.error('Error executing query:', error);
            return res.status(500).send('Error fetching data from database');
        }

        // Send the fetched data as JSON response
        res.json(results);
    });
});

// Start the server
const port = 3000;
app.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});

**client side code in javascript:
**

fetch('/dataFood')
    .then(response => {
        if (!response.ok) {
            throw new Error('Network response was not ok');
        }
        return response.json();
    })
    .then(data => {
        console.log('Data received from server:', data);

        // Create a container for the data
        const dataContainer = document.getElementById('dataContainer');

        // Iterate over the data and create an element for each item
        data.forEach(item => {
            // Create a new div element for the item
            const itemDiv = document.createElement('div');
            itemDiv.className = 'item';

            // Create a new h2 element for the item name
            const itemName = document.createElement('h2');
            itemName.textContent = item.name; // Assuming 'name' is a property of the item

            // Create a new p element for the item description
            const itemDescription = document.createElement('p');
            itemDescription.textContent = item.description; // Assuming 'description' is a property    of the item

            // Append the item name and description to the item div
            itemDiv.appendChild(itemName);
            itemDiv.appendChild(itemDescription);

            // Append the item div to the data container
            dataContainer.appendChild(itemDiv);
        });
    })
    .catch(error => {
        console.error('There was a problem with the fetch operation:', error);
    });

**this is the html code:
**

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Data Page</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <h1>Data from MySQL Database</h1>
  <div id="dataContainer" class="data-container"></div> <!-- Container for data -->
  <script src="script.js"></script> <!-- Include your JavaScript file -->
</body>

</html>

this is the output I get:

enter image description here

this is my github: https://github.com/SulimanGR/Async

feel free to view my code for further code inspection.

Function is not called after saving to firebase emulator storage

When I upload a file to the emulator’s storage, onUploadFile is not called. I have no idea what the cause is.version “express”: “^4.18.2″,”firebase-admin”: “^11.8.0″,”firebase-functions”: “^4.6.0”.
There are no errors in the emulator, and the storage is still there.

export const onUploadFile = functions.storage .object()
.onFinalize(async (object) => {
console.log(object);
console.log(“test”); });

This did not work.

import { useState, ChangeEvent } from 'react';

import { ref, uploadBytes } from 'firebase/storage';
import { storage } from '../firebaseConfig';

export const Upload = () => {
  const [file, setFile] = useState<File | null>(null);

  const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
    const files = event.target.files;
    if (files) {
      setFile(files[0]);
    }
  };

  const handleUpload = async () => {
    if (file) {
      const storageRef = ref(storage, `/${file.name}`);
      console.log(storageRef, 'storageRef');
      try {
        const snapshot = await uploadBytes(storageRef, file);
        console.log(
          snapshot.metadata.fullPath
        );
      }
    }
  };

  return (
    <div>
      <input type="file" onChange={handleFileChange} />
      <button onClick={handleUpload}>upload</button>
    </div>
  );
};

import * as functions from "firebase-functions";
import app from "./server/server";
// eslint-disable-next-line object-curly-spacing
import { onObjectFinalized } from "firebase-functions/v2/storage";

export const api = functions
  .runWith({
    timeoutSeconds: 500,
  })
  .https.onRequest(app);

export const onUploadFile = onObjectFinalized(async (object) => {
  console.log(object, "test");
});

{
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ],
      "predeploy": [
        "npm --prefix "$RESOURCE_DIR" run lint",
        "npm --prefix "$RESOURCE_DIR" run build"
      ]
    }
  ],
  "hosting": {
    "public": "frontend/build",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "/api/**",
        "function": "api"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "storage": {
    "rules": "storage.rules"
  },
  "emulators": {
    "functions": {
      "port": 5001
    },
    "hosting": {
      "port": 5002
    },
    "auth": {
      "port": 9099
    },
    "storage": { "port": 9199 }
  }
}

How to get fetch status code when it fails with “TypeError: Failed to fetch”?

I have the following code:


    let response = null;
    try {
      response = await fetch(url, { method,
        headers: {
          Authorization: `Bearer ${accessToken}`,
        }
      });
      console.log("Status", response?.status);
    } catch (e) {
      console.log("Error", e);
      console.log("Response", response);
    }

My request fails with status code 403, but I cannot get this 403 from nowhere. The code above doesn’t get to the line console.log("Status", response?.status);, instead it goes into catch section, where response is undefined and e is error with message "TypeError: Failed to fetch" and stacktrace, but without any further details about the response (actually, I looked for response status code).

screenshot of failed fetch with 403 status code

Does anybody have idea how do I get that status code (403 in my example) when fetch fails into catch section?

Hide and Show toggle for multiple buttons – Only toggle one content – Javascript

I was researching for a way to put a toggle on multiple buttons to hide/show content but all buttons keep toggling the same content.

Is there something wrong with my code?


<body>
  <button id="d4btn" onclick="myFunction('div1')">Text</button>
  <div id="div1"></div>
  <p></p>

</body>

<body>
  <button id="d2btn" onclick="myFunction('div2')">Text2</button>
  <div id="div2"></div>
  <p></p>

</body>

<body>
  <button id="r2btn" onclick="myFunction('div3')">Text3</button>
  <div id="div3"></div>
  <p></p>

</body>

<script>
    function myFunction('div1') {
  var x = document.getElementById("d4-container");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
</script>

<script>
    function myFunction('div2') {
  var x = document.getElementById("d2-container");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
</script>
<script>
    function myFunction('div3') {
  var x = document.getElementById("r2-container");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
</script>

Most of the times doesn’t even show any content after clicking, not sure what to do next.

First I was trying with one button and one function and it worked without problems, but to use multiple buttons they keep toggling the same content.

I must say that this is my first time trying to code something, I’m building my own website using elementor so I never had to do anything like this before.

Appreciate any suggestions (if possible, to someone who doesn’t code)

Finding first option in select that matches a regex pattern [duplicate]

I have a select with options of company names as the text and company ID as value. I also have an input where a user can enter 3 or more characters, the purpose of which is to find the first option that begins with what they’ve typed.

I tried using this…
Array.from(document.querySelector('select#company_name_select').options).findIndex((option) => option.text.match(/^acc/i))

…which works just fine and returns the correct index. However, I need to replace the “acc” with the text the user entered, but if I do…
let pattern = '/^' + evt.target.value + '/i';
…because it puts the pattern into a string, it is not working.

This can be shown by doing this instead…
Array.from(document.querySelector('select#company_name_select').options).findIndex((option) => option.text.match(pattern))
…which always returns -1.

So the match works if the pattern is really a pattern, but not when the pattern is a string.
I’m sure this is something simple, and I could use jQuery which is already in the project, I’d just like to know the reason why.

Thanks

Tried using backticks with ${evt.target.value}, single quotes with concatenation, and double quotes also with concatenation.

Also tried let pattern = new RegExp() – with all quote types.

Issues exporting node.js mysql connection object

I’m making a discord.js bot that connects to a mysql database and I’m using the mysql2 node.js package.

There’s two relevant files query.js and index.js

Index.js:

//...more code above
var mysql      = require('mysql2');
const { waitForDebugger } = require('node:inspector');
var connection = mysql.createConnection({
  host     : '127.0.0.1',
  user     : 'root',
  password : process.env.dbPass,
  database : 'ucbot_db'
});
 
connection.connect();

//this part is just to test if the connection works, which it does
connection.query('SELECT * from clans', function (error, results, fields) {
    if (error) {
        console.log(`Error: ${error}`);
    }
    console.log(`${JSON.stringify(results)}`);
});

module.exports = {connection};

Query.js

const { SlashCommandBuilder } = require('@discordjs/builders');
const { connection } = require('../index.js');

console.log(connection);

connection is undefined and I cannot figure out why.
The file structure is like this

Root folder
|-commands
|-|-query.js
|
|-index.js

Vue.js: PNG image not loading in new tab in production build

I’m building a Vue.js application using Vite and Vue Router. I have an image WEBP that, when clicked, should open a PNG version of the image in a new tab. This works fine when I’m running the application locally using npm run dev, but when I build for production, I get a 404 error when I try to open the image in a new tab.

<div id="art-container">
  <a id="art-link" href="#" target="_blank" title="Loading...">
    <img id="art-image" class="w-auto max-h-96 mb-4 rounded-lg shadow-lg" alt="Artwork" loading="eager" />
  </a>
  <!-- rest of the code -->
</div>

router.js

import { createRouter, createWebHistory } from 'vue-router';

// Import pages here
import index from './views/index.vue';
import notFound from './views/notFound.vue';

const routes = [
  // system pages
  { path: '/', component: index },
  // catch-all route
  { path: '/:pathMatch(.*)*', component: notFound },
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router

vite.config.js

import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import { join, parse, resolve } from "path";

const entryPoints = getEntryPoints("index.html");

// convert to route paths
const dynamicRoutes = Object.keys(entryPoints).map(key => `/${key}`);

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  alias: {
    "~": __dirname,
  },
  build: {
    outDir: 'dist',
    base: '/',
    minify: 'esbuild',
    sourcemap: 'true',
    rollupOptions: {
      input: entryPoints,
    },
  },
})

function getEntryPoints(...paths) {
  const entries = paths.map(parse).map(entry => {
    const { dir, base, name, ext } = entry;
    const key = join(dir, name);
    const path = resolve(__dirname, dir, base);
    return [key, path];
  });
  
  const config = Object.fromEntries(entries);
  return config;
}

Full code hosted at GitLab

Why is my button not displaying the form? [duplicate]

I know there are other issues with the code, but I am just trying to focus on getting my button to display the form. When I click the Add Book button nothing is displayed and I cannot figure out why.

I would like to know if my OpenForm/Closeform functions are incorrect. I saw to add another line which is a EventListener however that also did not work. I do understand why they would be incorrect if they are.

I created a button that should run the OpenForm function when clicked that will display the form below. Then I created the form within

Set the default display of the form to None which should change with the OpenForm function above.

function OpenForm() {
  document.getElementById("myForm").style.display = "block";

}

function Closeform() {
  document.getElementById("myForm").style.display = "none";
}
document.getElementById('myForm').addEventListener('click', OpenForm())
.form-popup {
  display: none;
}
<button onclick="OpenForm()" class="open-button">Add Book</button>
<div id="myForm" class="form-popup">
  <form action="blah" type="get">
    <input type="text" name="author" onkeyup="formChanged" onchange="formChanged" />
    <label for="author">Author</label>
    <input type="text" name="title" onkeyup="formChanged" onchange="formChanged" />
    <label for="title">Title</label>
    <input type="number" name="pages" onkeyup="formChanged" onchange="formChanged" />
    <label for="pages">Pages</label>
    <input type="button" value="Submit" onclick="AddBookToLibrary()">
  </form>
</div>

Seeking Simplified Explanation and Improvements for JavaScript Tip Calculation Code [closed]

I’m fairly new to JavaScript and have written a piece of code to calculate tips based on the bill amount. The code decides to give a 15% tip for bills between 50 and 300 units, and a 20% tip for any other bill amounts. Then, it calculates the total amount (bill + tip) for each bill. Here’s the code snippet:

Here is the code:

const calcTip = function (bill) {
    return bill >= 50 && bill <= 300 ? bill * 0.15 : bill * 0.2;
}

const bills = [125, 555, 44];
const tips = [calcTip(bills[0]), calcTip(bills[1]), calcTip(bills[2])];
const totals = [bills[0] + tips[0], bills[1] + tips[1], bills[2] + tips[2]];

console.log(bills, tips, totals);

i was following a course to do that code but i didn’t really understand when the instructor explained this code any help if possible 🙂

Css Transition is intermittent and flaky

The goal is smooth transition of width change of a div.

First in css I have done:

.myclass{
   transition: width 0.75s linear;
}

Then in javascript I am doing:

const mydiv = document.querySelector('.myclass')
mydiv.style.setProperty('width', '596px')

I find sometimes the smooth transition takes place , sometimes it doesn’t.
I have checked with debugger that in both the cases code flows through the same path ie mydiv.style.setProperty('width', '596px'); and in both the cases transition: width 0.75s linear 0s; rule is not overridden by anything else.

ERR_HTTP_HEADERS SENT( ‘set’)

I’m receiving this issue “Cannot set headers after they are sent to the client” but i can’t figure out what is causing it. and when the error does not occur, null values are added to the database.

Here is my code:

exports.Create = (modelo, placa, ano) => {
return new Promise ((resolve, reject) => {

connection.query('INSERT INTO cars (modelo, placa, ano) VALUES (?, ?, ?)',[modelo, placa, ano], 
(error, results) => {

    if(error) { reject(error)}

    resolve(results)})
     }
  )
}


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

try {
    
    const { modelo, placa, ano } = req.body

    if(!modelo || !placa || !ano) {
    return res.status(500).json({Failed: 'field(s) are missing.'})
    }

    const results = await create.Create(modelo, placa, ano)
    return res.status(201).json(results)
    } 

catch (error) {
console.error(error)
}
}

Send client to cloudinary link upon button click

I’m using Next.js. The cloudinary url that gets generated from cloudinary.uploader.upload… is result.secure_url in my app/page.js file. The button code is in app/components/Cloudinary.js and is imported into app/page.js I’m stuck on how to make the button click direct the user to the cloudinary url. I believe I have to make some sort of GET request such as below for the url.

import { NextResponse } from "next/server"; export async function GET() { return NextResponse.json({ **unsure what would need to be in here** })}

How do I solve this android studio error?

I’m trying to start android studio through wsl on windows 10 and I am getting this error

Start Failed
Internal error. Please refer to https://code.google.com/p/android/issues

java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:40)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:599)
at java.desktop/java.awt.Toolkit.getEventQueue(Toolkit.java:1498)
at java.desktop/java.awt.EventQueue.isDispatchThread(EventQueue.java:1104)
at java.desktop/javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1493)
at java.desktop/javax.swing.text.StyleContext.reclaim(StyleContext.java:473)
at java.desktop/javax.swing.text.StyleContext.addAttribute(StyleContext.java:330)
at java.desktop/javax.swing.text.html.StyleSheet.addAttribute(StyleSheet.java:607)
at java.desktop/javax.swing.text.StyleContext$NamedStyle.addAttribute(StyleContext.java:1558)
at java.desktop/javax.swing.text.StyleContext$NamedStyle.setName(StyleContext.java:1368)
at java.desktop/javax.swing.text.StyleContext$NamedStyle.(StyleContext.java:1315)
at java.desktop/javax.swing.text.StyleContext.addStyle(StyleContext.java:125)
at java.desktop/javax.swing.text.StyleContext.(StyleContext.java:105)
at java.desktop/javax.swing.text.html.StyleSheet.(StyleSheet.java:167)
at com.intellij.ide.ui.html.GlobalStyleSheetHolder.(GlobalStyleSheetHolder.kt:34)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at com.intellij.idea.StartupUtil$preloadLafClasses$1.invokeSuspend(StartupUtil.kt:523)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Suppressed: java.awt.AWTError: Can’t connect to X11 window server using ‘172.28.208.1:0.0’ as the value of the DISPLAY variable.
at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:107)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:62)
at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:36)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:103)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:88)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:116)
at java.desktop/sun.awt.X11.XToolkit.(XToolkit.java:514)
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:40)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:599)
at com.intellij.idea.StartupUtil$initAwtToolkit$1$1.invokeSuspend(StartupUtil.kt:424)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
… 4 more
Caused by: java.lang.ExceptionInInitializerError: Exception java.awt.AWTError: Can’t connect to X11 window server using ‘172.28.208.1:0.0’ as the value of the DISPLAY variable. [in thread “DefaultDispatcher-worker-5”]
at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:107)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:62)
at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:36)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:103)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:88)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:116)
at java.desktop/sun.awt.X11.XToolkit.(XToolkit.java:514)
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:40)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:599)
at com.intellij.idea.StartupUtil$initAwtToolkit$1$1.invokeSuspend(StartupUtil.kt:424)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
… 4 more


Your JRE: 17.0.7+0-17.0.7b1000.6-10550314 amd64 (JetBrains s.r.o.)
/home/odongo/android-studio/jbr

Also, a UI exception occurred on an attempt to show the above message
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:40)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:599)
at java.desktop/java.awt.EventQueue.(EventQueue.java:264)
at java.desktop/sun.awt.SunToolkit.initEQ(SunToolkit.java:177)
at java.desktop/sun.awt.SunToolkit.createNewAppContext(SunToolkit.java:316)
at java.desktop/sun.awt.AppContext$2.run(AppContext.java:273)
at java.desktop/sun.awt.AppContext$2.run(AppContext.java:262)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/sun.awt.AppContext.initMainAppContext(AppContext.java:262)
at java.desktop/sun.awt.AppContext$3.run(AppContext.java:315)
at java.desktop/sun.awt.AppContext$3.run(AppContext.java:298)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/sun.awt.AppContext.getAppContext(AppContext.java:297)
at java.desktop/java.awt.Component.(Component.java:1023)
at java.desktop/java.awt.Container.(Container.java:300)
at java.desktop/javax.swing.JComponent.(JComponent.java:641)
at java.desktop/javax.swing.text.JTextComponent.(JTextComponent.java:317)
at java.desktop/javax.swing.JEditorPane.(JEditorPane.java:254)
at java.desktop/javax.swing.JTextPane.(JTextPane.java:100)
at com.intellij.idea.StartupErrorReporter.showMessage(StartupErrorReporter.java:85)
at com.intellij.idea.StartupErrorReporter.showMessage(StartupErrorReporter.java:39)
at com.intellij.idea.Main.main(Main.kt:71)
Caused by: java.lang.ExceptionInInitializerError: Exception java.awt.AWTError: Can’t connect to X11 window server using ‘172.28.208.1:0.0’ as the value of the DISPLAY variable. [in thread “DefaultDispatcher-worker-5”]
at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:107)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:62)
at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:36)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:103)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.(GraphicsEnvironment.java:88)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:116)
at java.desktop/sun.awt.X11.XToolkit.(XToolkit.java:514)
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:40)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:599)
at com.intellij.idea.StartupUtil$initAwtToolkit$1$1.invokeSuspend(StartupUtil.kt:424)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

I was trying to start android studio