API Gateway “failed to fetch” when using Cognito User Pool Authentication

I have a REST API that triggers a Lambda function to return some data from a DynamoDB table. Everything was working when I had no authorization in the process with my fetch statement looking like:

function fetchData(){
  const itemID = encodeURIComponent('item#123');
  const url = "https://domain1234.execute-api.region.amazonaws.com/stage/item/" + itemID;
  fetch(url)
  .then(response =>{
    return response.json()
  }).then(jsonData =>{
    console.log(jsonData)
  }).catch(e =>{
    console.log(e.message)
  })
}

I then included authorization through Cognito with the following steps.

  1. I added the pool as an Authorizer in the “Authorizers” section of API Gateway. Setting the token source as “Authorization”

  2. Tested the Authorizer using a Cognito idToken after logging in and pasting into the test. The test was successful.

  3. Set each method to use that Cognito pool.

When I re-write the fetch to include a Authorization header I get a failed to fetch error.

The updated fetch is as follows:

function fetchData(){
  const itemID = encodeURIComponent('item#123');
  const url = "https://domain1234.execute-api.region.amazonaws.com/stage/item/" + itemID;
  fetch(url,{
  headers: {"Authorization":"myVeryLongIdToken"}
})
  .then(response =>{
    return response.json()
  }).then(jsonData =>{
    console.log(jsonData)
  }).catch(e =>{
    console.log(e.message)
  })
}

If I wasn’t being authorized, I would have expected a different unauthorized error – does this mean I’ve formatted my headers incorrectly?

How can I add a class to the AG-Grid floating filter?

I was wondering if it is possible to add a headerClass to the floating-filter or if there is any way to add a class to the floating-filter.

We are currently working on a normal view and compact view of our grid. When the ‘compact’ class is added the grid is made smaller. For the header I can use the ‘headerClass’ property in the colDef. But this ‘headerClass’ does not apply to the floating filter.

Floating-filter

Integrate keypress events into jQuery functions for accessibility

I’m looking to optimise my jQuery functions on a recently built site for accessibility, for instance quite a few functions I used either have a hover or mouseover event as the main event listener, but to make these sections fully accessibly via keyboard ideally they need to have an keypress/keyup trigger also.

I’ve seen a few examples of people using keypress then wrapping the function in an if statement to match it to the enter key, but this will then disable any other trigger.

Does anyone have any ideas of how I can integrate the keypress into my simple mouseover event below for example:

$('.insight-featured').on('mouseover', function() {
  $(this).parent().next().children('.hover-frame').css({"opacity" : '1', "scale" : "1"})
})

svg are not seen on iphone

I have a problem with my code, I have an animation of an SVG, and it shows on all devices except iPhones.

I can’t find solutions. here is the code of the SVG

<div class="contenuto-svg">
  <svg viewBox="-85 -85 170 170" xmlns="http://www.w3.org/2000/svg">
        <defs>
            <filter id="blur">
               <feGaussianBlur stdDeviation="4.8" />
            </filter>
            <linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="10%" stop-color="#9DB6F2" />
                <stop offset="70%" stop-color="#FF5321" />
                <stop offset="20%" stop-color="#FF2E00" />
            </linearGradient>
        </defs>
        <path fill="url(#gradient)" style="opacity: 1;" filter="url(#blur)">
            <animate attributeName="d" dur="20000ms" repeatCount="indefinite"
                         values="M46.8,-53.3C55.6,-48.4,54.1,-28.9,52.8,-12.8C51.5,3.3,50.4,15.8,43.8,23.4C37.2,31,25.2,33.7,11.7,43.5C-1.7,53.2,-16.7,70.1,-28.8,69.8C-40.8,69.4,-49.9,51.7,-56.8,35.1C-63.7,18.4,-68.4,2.8,-67.8,-13.9C-67.2,-30.5,-61.2,-48.2,-49,-52.4C-36.8,-56.7,-18.4,-47.5,0.3,-47.9C19,-48.3,38,-58.1,46.8,-53.3Z;
 M38.9,-46.9C53,-34.5,69,-24.7,67.4,-14.7C65.8,-4.7,46.7,5.6,36.9,20C27,34.3,26.5,52.7,19.6,56.2C12.8,59.7,-0.3,48.3,-11.3,40.3C-22.3,32.3,-31.1,27.7,-34.4,20.5C-37.7,13.4,-35.5,3.8,-38.3,-11.3C-41.1,-26.5,-48.9,-47,-43.4,-61C-37.8,-75,-18.9,-82.3,-3.3,-78.4C12.4,-74.5,24.7,-59.3,38.9,-46.9Z;
                            
                                                    M25.6,-33.4C38.3,-19.9,57.2,-16.7,65.6,-6.1C74.1,4.6,72.1,22.5,62.9,34.2C53.6,45.8,37.1,51.1,19.7,59.9C2.4,68.7,-15.7,80.9,-24.3,74.4C-32.9,68,-32,43,-36.8,25.6C-41.7,8.2,-52.5,-1.5,-50.6,-8.3C-48.7,-15.2,-34.1,-19.3,-23.6,-33.2C-13.1,-47,-6.5,-70.7,0,-70.7C6.5,-70.7,13,-46.9,25.6,-33.4Z;
                                                    
                                                    M36.1,-40.2C51.4,-30.3,71.5,-23.2,71.4,-14C71.3,-4.8,51.1,6.5,37.5,13.8C23.9,21.1,17,24.4,6.9,35C-3.2,45.7,-16.5,63.7,-23.2,62C-30,60.3,-30.2,38.9,-33.3,23.9C-36.4,8.9,-42.4,0.2,-46.9,-14.2C-51.4,-28.5,-54.5,-48.6,-46.4,-59.7C-38.4,-70.9,-19.2,-73.2,-4.4,-68C10.4,-62.8,20.9,-50.1,36.1,-40.2Z;
                            
                                                    M35.5,-41.2C48.2,-31.7,62.1,-22.5,70.7,-7.5C79.3,7.6,82.5,28.5,73.4,40.6C64.3,52.6,42.9,55.7,26.4,53.4C10,51,-1.4,43.2,-11.9,37.3C-22.3,31.5,-31.7,27.6,-36.2,20.6C-40.7,13.5,-40.2,3.2,-38.7,-7.1C-37.3,-17.5,-34.7,-27.9,-28.1,-38.5C-21.5,-49,-10.7,-59.7,0.3,-60.1C11.4,-60.5,22.8,-50.7,35.5,-41.2Z;
                                                    
                                                    M34.2,-37.4C48.6,-28.8,67.2,-22,69.5,-11.9C71.8,-1.7,57.7,11.7,46.2,22.1C34.8,32.5,26,40,15.8,44C5.5,47.9,-6.2,48.5,-17.9,45.7C-29.6,42.9,-41.3,36.7,-54.5,25.7C-67.8,14.7,-82.6,-1.3,-79.2,-12.8C-75.8,-24.4,-54.2,-31.6,-37.9,-39.8C-21.7,-48.1,-10.8,-57.4,-0.4,-56.9C10,-56.3,19.9,-46,34.2,-37.4Z;
                            
                                                    M46.8,-53.3C55.6,-48.4,54.1,-28.9,52.8,-12.8C51.5,3.3,50.4,15.8,43.8,23.4C37.2,31,25.2,33.7,11.7,43.5C-1.7,53.2,-16.7,70.1,-28.8,69.8C-40.8,69.4,-49.9,51.7,-56.8,35.1C-63.7,18.4,-68.4,2.8,-67.8,-13.9C-67.2,-30.5,-61.2,-48.2,-49,-52.4C-36.8,-56.7,-18.4,-47.5,0.3,-47.9C19,-48.3,38,-58.1,46.8,-53.3Z;
                                                    ">
            </animate>
        </path>
     </svg>
</div>

Handling Multiple File Inputs in React Using useRef Array Returns Undefined

I am working on a React application where I am dynamically rendering multiple file input elements using the Swiper component and Dropzone. However, when I attempt to gather all the files selected by these inputs during form submission, I consistently get undefined.

Here’s a simplified version of my code:

My Home component:

const Home = () => {
  const fileInputRefs = useRef<React.RefObject<HTMLInputElement>[]>([]);
  //...other hooks and useEffects

  const handleSubmit = async () => {
    const filesToUpload = fileInputRefs.current.map(
      (ref) => ref.current?.files?.[0]
    );
    for (let i = 0; i < filesToUpload.length; i++) {
      const fileToUpload = filesToUpload[i];
      console.log(`Selected file from input ${i}:`, fileToUpload);
      //...rest of the code for upload
    }
  };
  //...other methods and render
};

My SwiperComponent:

  //...hooks and methods

  const slides = images.map((image, index) => /*...*/);

  for (let i = images.length; i < 10; i++) {
    const ref = React.createRef<HTMLInputElement>();
    if (fileInputRefs.current) {
      fileInputRefs.current.push(ref);
    }
    slides.push(
      <SwiperSlide key={i}>
        <Dropzone
          onDrop={onDrop}
          setFiles={setFiles}
          ref={fileInputRefs[i]}
        />
      </SwiperSlide>
    );
  }
  //...render
};

My Dropzone:

  ({ onDrop, setFiles }, ref) => {
    const handleFileInput = (event: React.ChangeEvent<HTMLInputElement>) => {
      if (event.target.files) {
        const filesArray = Array.from(event.target.files);
        onDrop(filesArray);
        setFiles(filesArray);
      }
    };
    //...other methods and render
  }
);

The console output always prints Selected file from input X: undefined for each input. It seems like the file inputs are not correctly populated with the selected files. Can anyone spot what I might be doing wrong? Thank you in advance!

docker-compose up apache does not start

I’m trying to run a project. The logs seems ok, but i can’t reach my https://localhost.

docker-compose.yml

version: '3.5'

services:
    ## Reverse proxy Apache pour avoir un contexte https ISO prod
    apache:
        image: xxx:2.4.52-alpine
        container_name: office-4e28-apache
        network_mode: "host"
        volumes:
            - ./images/apache/configs/httpd.conf:/usr/local/apache2/conf/httpd.conf
            - ./images/apache/configs/site.conf:/usr/local/apache2/conf/extra/site.conf
            - ./images/apache/configs/xxx.local.crt:/usr/local/apache2/ssl/xxx.local.crt
            - ./images/apache/configs/xxx.local.key:/usr/local/apache2/ssl/xxx.local.key

when I run docker-compose up apache

there is no port 443 occupied (or even 80),
I tried to see if it work, but the command

sudo netstat -tulpn

doesn’t return our port.

I see warnings like

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message

into the logs, but they don’t have to be blocking.

How can I access the Event object of a mousedown Vuejs event?

I have a Vue component (Vue 2.5) using typescript.

I have a @mousedown event which launch mouseDown function :

<td
  v-for="hour in hours"
  @mousedown="mouseDown(day.index, hour, temperature_mode)"
  @mouseup="isMouseDown = false"
>

mouseDown(day: number, hour: number, value: number) {
   this.isMouseDown = true;
   this.setScheduledTempMode(day, hour, value);
}

I want to access the event object of this event.

I tried something like this :

mouseDown(e: Event, day: number, hour: number, value: number) {
   this.isMouseDown = true;
   this.setScheduledTempMode(day, hour, value);
   console.log(e);
}

But the log renders the day parameter value.

I tried also :

  • change the type to “any” but I have the same result.
  • move “e: Event” at the end of parameters, the result of the log is “undefined”.

So how can I retrieve the event object?

Is this the type that is not good?

Thanks

How do i fix the error “unknown type “queryName” ” on redwood js?

Using redwood JS framework, i’m trying to make queries to the database using graphQL. problem is that i get an error when i try to generate types :

Error 0: Unknown type “FindEditEventQueryVariables”.
at /home/alaborde/lisaquapp/app/web/src/components/EditEventCell/EditEventCell.tsx:1:47

it’s crazy because i want to generate type for that BUT it doesn’t wan’t to generate because the type doesn’t exist. it’s an infinite loop. what should i do ?

i’m kinda new to the web dev world and i don’t know a lot about queries.

Here’s the code i wrote for this cell :

import type {
  FindEventListQuery,
  FindEventListQueryVariables,
} from 'types/graphql'
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web'
import EventList from '../EventList/EventList'

export const QUERY = gql`
  query FindEventListQuery($id: Int!) {
    event: event(typeId: $id) {
      id
      description
      criticalityId
      typeId
      idTank
      idWater
      idBatch
      createdAt
      createdBy
    }
  }
`

export const Loading = () => <div>Loading...</div>

export const Empty = () => <div>Empty</div>

export const Failure = ({
  error,
}: CellFailureProps<FindEventListQueryVariables>) => (
  <div style={{ color: 'red' }}>Error: {error?.message}</div>
)

export const Success = ({
  event,
}: CellSuccessProps<FindEventListQuery, FindEventListQueryVariables>) => {
  return (
    <EventList eventsList={event}/>
  )
}

i’ll quickly explain what i want to achieve with this query :

I want to get all events which have the same TankId.

Any idea on what to do here ?

I want to call the change event within the click event in angular

My goal is to detect the cancel buton click while uploading a file. I am trying to achieve this by invoking the click event. Then after the event is triggered, it will detect the change event. If the change event triggers, it will upload the document else if the cancel button is clicked(means the change event did not trigger) then it will throw an error.

<input type="file" formControlName="receipt" (click)="fileDeetect($event)" (change)="uploadReceipt($any($event.target).files)"
                  class="positionabsolute" style="opacity: 0; width: 0; height: 0" id="validatedCustomFile" required />

I tried to achieve it by using the angular form validator markAsTouched(). But it did not work as it will work once the file is uploaded.

Map New array of object from array of object javascript

I have one array of object. I want to map new array.

I want to create this array into another array of object like this

let arr = [{
    "rn": "1",
    "EnergyParameterId": "4",
    "CountryId": "1",
    "CountryName": "Bangladesh ",
    "EnergySourceId": "1",
    "SourceName": "Nuclear",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "2",
    "EnergyParameterId": "4",
    "CountryId": "1",
    "CountryName": "Bangladesh ",
    "EnergySourceId": "2",
    "SourceName": "Fossil fuels",
    "UnitId": "",
    "Y_2011": "176",
    "Y_2012": "144",
    "Y_2013": "218",
    "Y_2014": "159",
    "Y_2015": "149",
    "Y_2016": "154.7000",
    "CAGR": "-2.55"
  },
  {
    "rn": "8",
    "EnergyParameterId": "4",
    "CountryId": "1",
    "CountryName": "Bangladesh ",
    "EnergySourceId": "8",
    "SourceName": "Biomass and waste",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "9",
    "EnergyParameterId": "4",
    "CountryId": "1",
    "CountryName": "Bangladesh ",
    "EnergySourceId": "9",
    "SourceName": "Hydroelectric pumped storage",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  }, {
    "rn": "10",
    "EnergyParameterId": "4",
    "CountryId": "1",
    "CountryName": "Bangladesh ",
    "EnergySourceId": "11",
    "SourceName": "Generation",
    "UnitId": "",
    "Y_2011": "771",
    "Y_2012": "882",
    "Y_2013": "1103",
    "Y_2014": "1159",
    "Y_2015": "1183",
    "Y_2016": "1214.7000",
    "CAGR": "9.52"
  },
  {
    "rn": "11",
    "EnergyParameterId": "4",
    "CountryId": "5",
    "CountryName": "Czech Republic ",
    "EnergySourceId": "1",
    "SourceName": "Nuclear",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "12",
    "EnergyParameterId": "4",
    "CountryId": "5",
    "CountryName": "Czech Republic ",
    "EnergySourceId": "2",
    "SourceName": "Fossil fuels",
    "UnitId": "",
    "Y_2011": "1545",
    "Y_2012": "2286",
    "Y_2013": "3242",
    "Y_2014": "4172",
    "Y_2015": "4212",
    "Y_2016": "4273.2400",
    "CAGR": "22.56"
  },
  {
    "rn": "13",
    "EnergyParameterId": "4",
    "CountryId": "5",
    "CountryName": "Czech Republic ",
    "EnergySourceId": "3",
    "SourceName": "Hydroelectricity",
    "UnitId": "",
    "Y_2011": "3967",
    "Y_2012": "3734",
    "Y_2013": "4719",
    "Y_2014": "4991",
    "Y_2015": "5037",
    "Y_2016": "5757.0000",
    "CAGR": "7.73"
  },
  {
    "rn": "22",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "2",
    "SourceName": "Fossil fuels",
    "UnitId": "",
    "Y_2011": "769",
    "Y_2012": "731",
    "Y_2013": "742",
    "Y_2014": "732",
    "Y_2015": "746",
    "Y_2016": "760.0000",
    "CAGR": "-0.24"
  },
  {
    "rn": "23",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "3",
    "SourceName": "Hydroelectricity",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "24",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "4",
    "SourceName": "Geothermal",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "25",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "5",
    "SourceName": "Tide and wave",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "26",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "6",
    "SourceName": "Solar",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "1",
    "Y_2013": "2",
    "Y_2014": "6",
    "Y_2015": "10",
    "Y_2016": "10.7120",
    "CAGR": "0.00"
  },
  {
    "rn": "27",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "7",
    "SourceName": "Wind",
    "UnitId": "",
    "Y_2011": "113",
    "Y_2012": "135",
    "Y_2013": "151",
    "Y_2014": "153",
    "Y_2015": "165",
    "Y_2016": "134.0000",
    "CAGR": "3.47"
  },
  {
    "rn": "28",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "8",
    "SourceName": "Biomass and waste",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "4.8000",
    "CAGR": "0.00"
  },
  {
    "rn": "29",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "9",
    "SourceName": "Hydroelectric pumped storage",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "30",
    "EnergyParameterId": "4",
    "CountryId": "8",
    "CountryName": "Honduras ",
    "EnergySourceId": "11",
    "SourceName": "Generation",
    "UnitId": "",
    "Y_2011": "882",
    "Y_2012": "867",
    "Y_2013": "895",
    "Y_2014": "891",
    "Y_2015": "921",
    "Y_2016": "909.5120",
    "CAGR": "0.62"
  },
  {
    "rn": "35",
    "EnergyParameterId": "4",
    "CountryId": "13",
    "CountryName": "Sri Lanka ",
    "EnergySourceId": "5",
    "SourceName": "Tide and wave",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "36",
    "EnergyParameterId": "4",
    "CountryId": "13",
    "CountryName": "Sri Lanka ",
    "EnergySourceId": "6",
    "SourceName": "Solar",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "8",
    "Y_2015": "8",
    "Y_2016": "8.2500",
    "CAGR": "0.00"
  },
  {
    "rn": "37",
    "EnergyParameterId": "4",
    "CountryId": "13",
    "CountryName": "Sri Lanka ",
    "EnergySourceId": "7",
    "SourceName": "Wind",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "38",
    "EnergyParameterId": "4",
    "CountryId": "13",
    "CountryName": "Sri Lanka ",
    "EnergySourceId": "8",
    "SourceName": "Biomass and waste",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "39",
    "EnergyParameterId": "4",
    "CountryId": "13",
    "CountryName": "Sri Lanka ",
    "EnergySourceId": "9",
    "SourceName": "Hydroelectric pumped storage",
    "UnitId": "",
    "Y_2011": "0",
    "Y_2012": "0",
    "Y_2013": "0",
    "Y_2014": "0",
    "Y_2015": "0",
    "Y_2016": "0.0000",
    "CAGR": "0.00"
  },
  {
    "rn": "40",
    "EnergyParameterId": "4",
    "CountryId": "13",
    "CountryName": "Sri Lanka ",
    "EnergySourceId": "11",
    "SourceName": "Generation",
    "UnitId": "",
    "Y_2011": "22877",
    "Y_2012": "23289",
    "Y_2013": "24361",
    "Y_2014": "25626",
    "Y_2015": "26783",
    "Y_2016": "26807.6500",
    "CAGR": "3.22"
  }
];
console.log(arr);

I want to convert this into

let newArr = [{
‘CountryName’: srilanka,
‘SourceName’: Nuclear,
‘data’: [0,0,0,0,0,0]
}];

I have tried to loop and map but it did not worked for me…

let createArrLineChart = [];
debugger;
for (let index = 0; index < newArr ; index++) {
// const element = this.ArrGetEnergyStatisticsData.EnergyStatistics.Data[index];
// let createObj:any = {};
// createObj.Name = element.CountryName;
// createArrLineChart.push(createObj)
var result:any = this.ArrGetEnergyStatisticsData.EnergyStatistics.Data.map((person: any) => {
person.startsWith(“Y_”);
});
console.log(result)
console.log(this.ArrGetEnergyStatisticsData.EnergyStatistics.Data[index]);
}

How can i do this?

how do i activate my nodejs function from another js file?

I have a database where i store all of my users that log in into my website and wanted to make it possible for them to delete their acc. So i made a function that works and can delete users their accs, but i the only problem that i’m having is that i can’t seem to connect the js file that has the eventlistener for the button with my nodejs file with the function.

// node.js file
let id = 1;
/* delete user from mysql db */
async function delUsers() {
    /* actually hardcoded id, need to implement users id when a user can login into the site */
    await pool.query('DELETE FROM user WHERE id = ?', [id]);
    console.log("Deleting..");

};
// js file
'use strict';
console.log('linked');
let del = document.getElementById('delbutton').addEventListener('click', Del);
let a = require('./delete.js');
function Del() {
let b = a.DelUser();
}

I tried using module.exports with module.import, require, sessionstorage, localstorage. I expected my button to work and remove 1 of my users

Selenium Python – Trying to driver.execute_script but get “None” while testing background-image

I’m trying to test a background-image with Selenium. It doesn’t have <img> tag, it have this html code (it is banner from https://openweather.co.uk/products page):

<div class="current-img white-text half-section-right main-section-desktop"></div>

and this CSS styles

This JavaScript code works well in DevTools console:

    const image = new Image(); 
    image.src = 'https://openweather.co.uk/themes/openweather_b2b/assets/img/forecast-banner.jpg';
    image.onload = function(){
    const imageWidth = this.width; 
    const imageHeight = this.height;
    console.log('Width:', imageWidth, 'Height:', imageHeight);
    };

But how to implement this JS code to driver.execute_script and get imageWidth and imageHeight back to Python code?

If I just pass this code into driver.execute_script("here") I got None.
If replace last line with return('Width:', imageWidth, 'Height:', imageHeight); I got None too.

And in general – how to return data from driver.execute_script back to Python correctly?
For example driver.execute_script("return console.log('Hi');") gives None too.