Connection from DB to HTML

<body>
    <div class="main-body">
       
        <div class="hotel-block">
            <img src="https://i2.photo.2gis.com/images/branch/0/30258560076741797_1cd9.jpg" alt="" class="hotel-1">
            <h2></h2>
            <p class="chertochka"></p>
            <h2></h2>
            <a class="click-btn btn-style2" href="./contact.html">List</a>
        </div>
        <div class="hotel-block">
            <img src="https://avatars.dzeninfra.ru/get-zen_doc/2404797/pub_5ec05dabc419064bb24dcdcb_5ec07408d54088764522e780/scale_1200" alt="" class="hotel-1">
            <h2></h2>
            <p class="chertochka"></p>
            <h2></h2>
            <a class="click-btn btn-style2" href="./contact.html">List</a>
        </div>
        <div class="hotel-block">
            <img src="https://www.worldrainbowhotels.com/wp-content/uploads/2019/05/Crown-Metropol-Perth.jpg" alt="" class="hotel-1">
            <h2></h2>
            <p class="chertochka"></p>
            <h2></h2>
            <a class="click-btn btn-style2" href="./contact.html">List</a>
        </div>
        <div class="hotel-block">
            <img src="https://alanya-invest.ru/upload/iblock/6e4/6e43b827a3ff50d381f95697957f30b5.jpg" alt="" class="hotel-1">
            <h2></h2>
            <p class="chertochka"></p>
            <h2></h2>
            <a class="click-btn btn-style2" href="./contact.html">List</a>
        </div>
        <div class="hotel-block">
            <img src="https://static.tildacdn.com/tild3537-6330-4633-a535-363963343564/IMG_5600_24-10-2018_.jpg" alt="" class="hotel-1">
            <h2></h2>
            <p class="chertochka"></p>
            <h2></h2>
            <a class="click-btn btn-style2" href="./contact.html">List</a>
        </div>
        <div class="hotel-block">
            <img src="https://s01.cdn-pegast.net/get/ff/7a/6a/14fc6c3317967b5913591d23b20ead97a39bc3027cc726ed1f4188c23a/5f3534cc2c556.jpg" alt="" class="hotel-1">
            <h2></h2>
            <p class="chertochka"></p>
            <h2></h2>
            <a class="click-btn btn-style2" href="./contact.html">List</a>
        </div>
    </div>
</body>
<footer>
    <div class="icons-list">
        <li class="icons">Phone number - 8 926 745 64 43</li>
        <li class="icons">Social Network - @grammyf</li>
    </div>
</footer>
<script src="bd.js">
const mysql = require('mysql');

const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'hotelsDB'
});

connection.connect((err) => {
  if (err) {
    console.error('Ошибка подключения к базе данных: ', err);
    return;
  }
  console.log('Подключение к базе данных успешно');

  connection.query('SELECT * FROM hotels', (err, rows) => {
    if (err) {
      console.error('Ошибка выполнения запроса: ', err);
      return;
    }

    const hotels = rows.map(row => {
      return {
        hotel_name: row.hotel_name,
        price: row.price,
        description: row.description
      };
    });

    'Массив отелей:', JSON.stringify(hotels)
    hotelsArray = hotels.splice(0, 6)
    console.log(JSON.stringify(hotelsArray.splice(0, 6)))
    
    module.exports = hotels; 
  });

  connection.end((err) => {
    if (err) {
      console.error('Ошибка закрытия соединения с базой данных: ', err);
      return;
    }
    console.log('Лан наебал оно опять открыто');
  });
});

const hotelBlocks = document.querySelectorAll('.hotel-block'); !!! 

hotelsArray.forEach(hotel => {
  const hotelElement = document.createElement('div');
  hotelElement.innerHTML = `
      <div class="hotel-block">
          <h2>${hotel.hotel_name}</h2>
          <p>Цена: $ ${hotel.price}</p>
          <p>${hotel.description}</p>
          <a class="click-btn btn-style2" href="./contact.html">List</a>
      </div>
  `;
  hotelsContainer.appendChild(hotelElement);
})
</script>

There is a data array in the variable hotelsArray that is formed as a result of the script. How can I transfer data from the JSON array to the HTML page? I tried selecting the .hotel-block tag and creating a loop for each element in the array to create div elements, but when I run the script in a separate file, it only outputs the array data. When I embed the script on the HTML page, the code doesn’t work. What can I do about this? I need to create divs with specific data on the page. How can I do this without using PHP, only JS and NodeJS

Prisma client error: cannot read properties of undefined

I have a web application built with an express.js backend, PostgreSQL db and use Prisma client. I have 2 separate POST routes in the app, /api/chat and /api/sendRecReview (code below). This web app is hosted on Render.

app.post("/api/chat", async (req, res) => {
  try {
    const clientIp = req.ip;
    const timestamp = new Date();
    const messageHistory =
      req.body.messageHistory.map((messageObj) => messageObj.User) || [];

    const answers = req.body.answers;

    console.log(messageHistory);
    const responseObj = await querydb(messageHistory, answers);
    const updatedMessageHistory = req.body.messageHistory.concat({
      AI: responseObj.text,
    });

    // Arrange club recs data to save in database
    const clubData = updatedMessageHistory[1].AI;
    const clubString = clubData.replace("```jsonn", "").replace("n```", "");
    const clubRecsToSave = JSON.parse(clubString);

    // Save IP address, timestamp, and recommendations to the database
    const session = await prisma.session.create({
      data: {
        clientIp: clientIp,
        timestamp: timestamp,
        answers: JSON.stringify(answers),
        recommendations: JSON.stringify(clubRecsToSave),
      },
    });

    res
      .status(200)
      .json({ messageHistory: updatedMessageHistory, clientIp: clientIp });
  } catch (error) {
    console.error(error);
    res
      .status(500)
      .json({ error: "An error occurred while processing the request" });
  }
});
app.post("/api/sendRecReview", async (req, res) => {

  try {
    const clientIp = req.ip; 
    const timestamp = new Date();
    const answers = req.body.answers;
    const recommendations = req.body.clubs;
    const rating = req.body.rating;

    const review = await prisma.review.create({
      data: {
        clientIp: clientIp, 
        timestamp: timestamp,
        answers: JSON.stringify(answers),
        recommendations: JSON.stringify(recommendations),
        rating,
      },
    });

    res.status(200).json({ response: "Rating Successful" });
  } catch (error) {
    console.error(error);
    res
      .status(500)
      .json({ error: "An error occurred while processing the request" });
  }
});
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Session {
  id              String   @id @default(uuid())
  clientIp        String
  timestamp       DateTime @default(now())
  answers         String
  recommendations String
}

model Review {
  id              String   @id @default(uuid())
  clientIp        String
  timestamp       DateTime @default(now())
  answers         String
  recommendations String
  rating          String
}

When I hit both routes in localhost, the data correctly saves to both the Session table and the Review table in the database. When I run these on the Render hosted site, the data is correctly saved to the Session table but not the Review table. I get the below error telling me review is undefined when I run .create on it.

TypeError: Cannot read properties of undefined (reading 'create')
at file:///opt/render/project/src/index.js:258:25
at Layer.handle [as handle_request] (/opt/render/project/src/node_modules/express/lib/router/layer.js:95:5)
at next (/opt/render/project/src/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (/opt/render/project/src/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (/opt/render/project/src/node_modules/express/lib/router/layer.js:95:5)
at /opt/render/project/src/node_modules/express/lib/router/index.js:284:15
at Function.process_params (/opt/render/project/src/node_modules/express/lib/router/index.js:346:12)
at next (/opt/render/project/src/node_modules/express/lib/router/index.js:280:10)
at /opt/render/project/src/node_modules/body-parser/lib/read.js:137:5
at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
==> Detected service running on port 10000
==> Docs on specifying a port: https://render.com/docs/web-services#port-binding

Migrations have been run and all code has been pushed to Github and deployed to Render. The only slight variation is the Review table was created separately as part of the second migration as where Session was part of the first migration. Can anyone think of why the Review table is not being recognized at runtime on Render but is working fine in localhost?

Difference between func.apply(this, args) and func(…args) in closures

I came across the following thing while trying to understand some concepts of working with closures.
When I was reading about memoization/throttling, people were using func.apply(this, args) in closures.

Here are some examples from 2 different sources:

function memoize(func) {
  const cache = {}
  return function(...args) {
    const key = JSON.stringify(args)
    if (cache[key]) {
      return cache[key]
    } else {
      const result = func.apply(this, args) // (*)
      cache[key] = result
      return result
    }
  }
}

and

function throttle(func, interval) {
  let isRunning = false;

  return function (...args) {
    if (!isRunning) {
      isRunning = true;
      func.apply(this, args); // (*)

      setTimeout(() => {
        isRunning = false;
      }, interval);
    }
  };
}

So my question is: can we use func(...args) instead? And what is the actual difference if we would call func with spread-operator instead of apply?

How to access Payload after accessing the Request url

Through Selenium in the Python language, I am working on testing the website, and I was able to access the link for the Request, and I want to access the Payload. Attached is an image that shows
enter image description here

driver = webdriver.Chrome(options=option)

driver.get("https://www.example.com")

network_entries = driver.execute_script(
    "return window.performance.getEntriesByType('resource');")

       
for entry in network_entries:
    target_url = entry['name']
    if("http://fonts.googleapis.com/css?family=Open" in target_url):
        

        print("URL:", target_url)
        # need print payload !!
        #print("PAYLOAD:", payload)

I keep getting net::ERR_BLOCKED_BY_CLIENT on the console and (status) blocked on the network tab

i have this code that makes a request to fetch an array from a laravel backend, on my local server, it runs smoothly but after i hosted it, i keep getting POST error “http://127.0.0.1:8000/retrieve net::ERR_BLOCKED_BY_CLIENT”

$.post("https://vgn.srgasaswsa.com", {
                // Retrieve CSRF token from the meta tag
                _token: document.querySelector(
                    '#registrationForm [name="_token"]'
                ).value,

                // Send the value of the selected item as a parameter
                data: item.value,
            })
                .done((res) => {
                    // Loop it as options in the corresponding Local government <select>
                    $.map(res, (item) => {
                        $(local).append(
                            ` <li class="hover:bg-red-800 hover:text-white hover:font-semibold">
                            <label for="${item}" class="w-full h-fit relative" x-on:click="isFocus = false, message = '${item}'">
                                <input type="radio"
                                            name="${local.substring(1)}"
                                            id="${item}"
                                            value="${item}"
                                            class="absolute top-0 left-0 w-full h-fit opacity-0 cursor-pointer"
                                >
                                <p class="w-full h-fit py-2 text-[50px] lg:text-[1em] lg:text-base font-normal">${item}</p>
                            </label>
                        </li>`
                        );
                    });
                })
                .fail((xhr, status, error) => {
                    console.error(error);
                });```

I changed the POST url affter hosting to the hosting url, but it still showing the same error, 

this is my laravel cors
'paths' => ['api/*', 'sanctum/csrf-cookie'],

'allowed_methods' => ['*'],

'allowed_origins' => ['https://vgn.srgasaswsa.com'],

'allowed_origins_patterns' => [],

'allowed_headers' => ['*'],

'exposed_headers' => [],

'max_age' => 0,

'supports_credentials' => true,

Embed cloudflare insights including sending data with javascript

I have the following html code to embed the Cloudflare Insights javascript into my website.

<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "001e2db377654356d03acf35f1e5a"}'></script>

Because of the cookie law in the EU, I only want to load the script when someone accepts cookies. Therefore I’ve a javascript function where I load those third-party scripts only when someone accepts cookies.

How can I embed the Cloudflare Insights script including sending the data-cf-beacon data with my javascript function? My function now loads the cloudflare script, but doesn’t send the data-cf-beacon.

function BlockCookie() {
        var imported = document.createElement('script');
        imported.src = 'https://static.cloudflareinsights.com/beacon.min.js';
        document.head.appendChild(imported);  
    } ```

Why do some libraries expose methods that does the same thing, but each in sync/async context?

Some libraries exposes two methods that essentialy does the same thing, but one of them runs in async context and the other in sync context.

Some examples are: unlink from fs/promises and unlinkSync from fs; compare, compareSync, hash and hashSync from bcrypt.

Why did they choose to do this? Is there any pros and cons of using sync or async depending on the context of my application?

Issues with Scroll Triggered animation on fixed element using CSS and Javascript

I have image animation that animates as the user scrolls down the page using CSS and Javascript and I have a fixed container so that the image animates in place as the user scrolls down. Once it is at a certain spot on screen below, it switches to relevant positioning to keep it in the parent element. I am having trouble getting it to return and scroll back up when user scrolls up again.

Here is link to the page: https://6bq.107.myftpupload.com/product/black-cherry-star-tabs/

I have tried animating this different ways but needs to have the long scroll effect while image is fixed. I am thinking I need to maybe add some additional JS to be able to scroll back up once it hits the stop area. I had to change the position from fixed to relevant to get it to stop at the stop point inside the parent div.

Please, any help appreciated.

How to give each element of an array of ojects a key

If I have an array that looks like:

arr =[ { id: ‘f794’,label: ‘Blue Bird’ } ]

how do I give the element of it a key so I get

arr =["myKey":{ id: 'f794',label: 'Blue Bird' } ]

I have tried several different ways, like

arr[0]= '"myKey"' + ":" + arr[0]

which gives me

[ "myKey:[object Object]" ]

How do I get arr =["myKey":{ id: 'f794',label: 'Blue Bird' } ]

Thanks

how to get the external ip of a kubernetes service in javascript?

I’m writing an api to create game servers that run in kubernetes. I need to create an endpoint that creates a deployment and a service and then returns the service’s external ip.
I can create both succesfully and if I run kubectl get svc after hiting the endpoint I see this:

$ kubectl get svc
NAME                 TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)           AGE
kubernetes           ClusterIP      10.96.0.1      <none>        443/TCP           3d21h
minecraft-service    LoadBalancer   10.96.172.60   localhost     25565:31683/TCP   5s

My problem is I can’t access the value under the column EXTERNAL-IP from javascript. I can’t use loadBalancer.ingress because this is for a game server, so there is no ingress created. And can’t use loadBalancer.loadBalancerIP because it’s undefined.
This is the code of my endpoint:

const express = require('express')
const k8s = require('@kubernetes/client-node')

const app = express()
const port = 3000

const kc = new k8s.KubeConfig()
kc.loadFromDefault()
const k8sApi = kc.makeApiClient(k8s.CoreV1Api)
const k8sAppsApi = kc.makeApiClient(k8s.AppsV1Api)

app.post('/api/server/', async (req, res) => {
    const deploymentDefinition = {
        apiVersion: 'apps/v1',
        kind: 'Deployment',
        metadata: {
            name: 'minecraft-deployment',
        },
        spec: {
            replicas: 1,
            selector: {
                matchLabels: {
                    app: 'game-server',
                },
            },
            template: {
                metadata: {
                    labels: {
                        app: 'game-server',
                        game: 'minecraft'
                    },
                },
                spec: {
                    containers: [
                        {
                            name: 'minecraft',
                            image: 'minecraft',
                            imagePullPolicy: 'Never'
                        },
                    ],
                },
            },
        },
    }

    const serviceDefinition = {
        kind: "Service",
        apiVersion: "v1",
        metadata: {
            name: "minecraft-service",
        },
        spec: {
            selector: {
                app: "game-server",
            },
            ports: [{
                protocol: "TCP",
                port: 25565,
                targetPort: 25565,
            }],
            type: "LoadBalancer"
        }
    }

    try {
        const createService = await k8sApi.createNamespacedService('default', serviceDefinition)
        const createDeployment = await k8sAppsApi.createNamespacedDeployment('default', deploymentDefinition)
        sleep(5000)
        const service = await k8sApi.readNamespacedService('minecraft-service', 'default')
        //console.log(createService.body.status.loadBalancer)
        // Por defecto, algunos kube-proxy y servicios solo llenarán 'status.loadBalancer.ingress[0].ip', otros llenarán 'status.loadBalancer.ingress[0].hostname'.
        console.log(service.body)
        //const ip = service.body.status.loadBalancer.ingress[0].ip || service.status.loadBalancer.ingress[0].hostname
        //res.json({ ip })

    } catch (error) {
        console.error(error)
        res.status(500).json({ error: error.toString() })
    }
})

console.log(service.body) prints this:

V1Service {
  apiVersion: 'v1',
  kind: 'Service',
  metadata: V1ObjectMeta {
    annotations: undefined,
    creationTimestamp: 2024-04-30T19:37:24.000Z,
    deletionGracePeriodSeconds: undefined,
    deletionTimestamp: undefined,
    finalizers: undefined,
    generateName: undefined,
    generation: undefined,
    labels: undefined,
    managedFields: [ [V1ManagedFieldsEntry] ],
    name: 'minecraft-service',
    namespace: 'default',
    ownerReferences: undefined,
    resourceVersion: '64833',
    selfLink: undefined,
    uid: '61a9ceed-6ed6-482e-b488-6c2da17fe4c4'
  },
  spec: V1ServiceSpec {
    allocateLoadBalancerNodePorts: true,
    clusterIP: '10.96.172.60',
    clusterIPs: [ '10.96.172.60' ],
    externalIPs: undefined,
    externalName: undefined,
    externalTrafficPolicy: 'Cluster',
    healthCheckNodePort: undefined,
    internalTrafficPolicy: 'Cluster',
    ipFamilies: [ 'IPv4' ],
    ipFamilyPolicy: 'SingleStack',
    loadBalancerClass: undefined,
    loadBalancerIP: undefined,
    loadBalancerSourceRanges: undefined,
    ports: [ [V1ServicePort] ],
    publishNotReadyAddresses: undefined,
    selector: { app: 'game-server' },
    sessionAffinity: 'None',
    sessionAffinityConfig: undefined,
    type: 'LoadBalancer'
  },
  status: V1ServiceStatus {
    conditions: undefined,
    loadBalancer: V1LoadBalancerStatus { ingress: undefined }
  }
}

Any idea how to do this? Thanks
By the way, I’m on Windows 11, Docker Desktop and running the Kubernetes that comes with it.

I tried sleeping after the creation of the service. Geting the service from the cluster after creating it. I tried accessing service.loadBalancer.ingress[0].ip but resulted in an error because ingress is undefined. Tried accessing service.loadBalancer.loadBalancerIP and service.loadBalancer.externalIPs but these two are undefined too. And Tried changing the version of kubernetes/client-node to 0.19 and 0.15 but all these variables remained undefined.

Custom gutenberg block doesn’t load viewScript file on the frontend even though it’s defined in blocks.json

I’ve been struggling with this for hours. I used the @wordpress/create-block package to generate a template for me to create my first block. I’ve managed to create a hero block with an image uploader etc.

However, now I’ve come to the point where I need to actually add JS to the frontend in order to make the image carousel functionality. For some reason unknown to me, my view.js file absolutely refuses to load up in the frontend.

With loading I mean doesn’t appear in HTML, and doesn’t show up in the network tab.

I’ve searched everywhere.

  • According to the docs it’s correctly defined in my blocks.json.
  • I’m not using a render_callback in my register_block_type, so I shouldn’t have to enqueue it myself manually.
  • I’ve removed and reinserted the block about 100 times thinking it was cache or whatever.

It’s just no use. The plugin directory for my custom block is right here: https://github.com/Danielvandervelden/wp-template/tree/master/wp-content/plugins/hero if you have a moment I’d very much appreciate any help in order to get this resolved.

Thank you!

Dom Purify to remove all non-breaking space

I am using dompurify for a RichText component I have. I was hoping to add in a rule that would remove all &nbps; in the string. Here is some example code:

const content = '<p style="color:blue">Hello<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>world</p>' 

const customSanitizer = {
   FORBID_ATTR: ['id', 'data-react-mount', 'data-react-props-id'],
   ALLOW_DATA_ATTR: false, 
}

const cleanedContent = DOMPurify.sanitize(content, customSanitizer)

the desired result is that the value of cleanedContent equals:

<p style="color:blue">Hello world</p> 

is there anything I can add to customSanitizer to implement this?

Error into my react native code using Gesture Handler

I’m using React Native Gesture Handler into a js file and when I run the code I receive this error

ERROR [react-native-gesture-handler] Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as ‘worklet’ if you wish to run them on the UI thread or use ‘.runOnJS(true)’ modifier on the gesture explicitly to run all callbacks on the JS thread.

CODE:

` import * as React from ‘react’;
import { View, Text, Dimensions } from ‘react-native’;
import styles from ‘../styles/style_home’
import * as Animatable from ‘react-native-animatable’
import {Canvas, Path, Skia} from ‘@shopify/react-native-skia’;
import {curveBasis, line, scaleLinear, scalePoint} from ‘d3’;
import DataPalmas from ‘../../assets/csvjson.json’
import Gradient from ‘./Gradient’
import XAxisText from ‘./XAxisText’;
import { clamp, runOnJS, useSharedValue, withDelay, withTiming } from ‘react-native-reanimated’;
import Cursor from ‘./Cursor’
import {
Gesture,
GestureDetector,
PanGestureHandlerEventPayload,
} from ‘react-native-gesture-handler’;
import {getYForX, parse} from ‘react-native-redash’;

export default function () {
    const [showCursor, setShowCursor] = React.useState(false)
    const animationLine = useSharedValue(0)
    const animationGradient = useSharedValue({x: 0, y: 0})
    const cx = useSharedValue(0)
    const cy = useSharedValue(0)

    React.useEffect(() => {
        animationLine.value = withTiming(1, {duration:2000})
        animationGradient.value = withDelay(2000, withTiming({x: 0, y: chartHeight}, {duration: 1000}))
    }, [])

    const chartHeight = 150
    const chartWidth = Dimensions.get('window').width
    const chartMargin = 20
    const data = DataPalmas

    const xDomain = data.map((dataPoint) => dataPoint.Data)
    const xRange = [chartMargin, chartWidth - chartMargin]
    const x = scalePoint().domain(xDomain).range(xRange).padding(0)
    const stepX = x.step()
    const max = Math.max(...data.map(val => val.Precipitacao))
    const min = Math.min(...data.map(val => val.Precipitacao))

    const yDomain = [min, max]
    const yRange = [chartHeight, 0]
    const y = scaleLinear().domain(yDomain).range(yRange)

    const curvedLine = line()
    .x(d => x(d.Data))
    .y(d => y(d.Precipitacao))
    .curve(curveBasis)(data)

    const linePath = Skia.Path.MakeFromSVGString(curvedLine)
    const path = parse(linePath.toSVGString())

    function handleGestureEvent(e){
        const clampValue = clamp(
            Math.floor(e.absoluteX / stepX) * stepX + chartMargin,
            chartMargin,
            chartWidth - chartMargin,
        )
        cx.value = clampValue
        cy.value = getYForX(path, Math.floor(clampValue))
    }
    const pan = Gesture.Pan()
        .onTouchesDown(() => {
            setShowCursor(true)
        })
        .onTouchesUp(() => {
            setShowCursor(false)
        })
        .onBegin(handleGestureEvent)
        .onChange(handleGestureEvent)

    return (
    <Animatable.View style={styles.container__graphic} animation={"fadeInLeft"}>
        <GestureDetector gesture={pan}>
            <Canvas
            style={{
                width: chartWidth, 
                height: chartHeight+30,
            }}>
                <Path 
                path={linePath} 
                style={'stroke'} 
                strokeWidth={2} 
                color={'#0bb861'} 
                strokeCap={'round'}
                start={0}
                end={animationLine}/>
                <Gradient
                    chartHeight = {chartHeight}
                    chartMargin = {chartMargin}
                    chartWidth = {chartWidth}
                    curvedLine = {curvedLine}
                    animationGradient = {animationGradient}
                />
                {data.map((dataPoint, index) => (
                    <XAxisText
                        x={x(dataPoint.Data)}
                        y={chartHeight}
                        text={dataPoint.Data}
                        key={index}
                    />
                ))}
                {showCursor && 
                <Cursor 
                    cx = {cx}
                    cy = {cy}
                    chartHeight = {chartHeight}
                />}
                
            </Canvas>
        </GestureDetector>
    </Animatable.View>
    );
}`

When I use ‘worklet’ into this function the app crashes when I click

function handleGestureEvent(e){
    **'worklet'**
    const clampValue = clamp(
        Math.floor(e.absoluteX / stepX) * stepX + chartMargin,
        chartMargin,
        chartWidth - chartMargin,
    )
    cx.value = clampValue
    cy.value = getYForX(path, Math.floor(clampValue))
}