Why the “Form” have a dobled elements? And I need to make a hack to fix it [closed]

Site lana18.ru was moved to new hosting and I set to it a new template. After it at the payment page, where user can chose the payment system, pricing plan and use promocode start working incorectly. And I find that submited form have elements, dobled. I use the code from console:

var myForm = document.getElementById("adminForm");
for (var i = 0; i < myForm.elements.length; i++) {
    console.log(i, '.', myForm.elements[i].name, ':',myForm.elements[i].value);
}

and find that few items are dobled:

 0 'plan_id[19]' '3' 
 1 '' ''  
 2 'plan_selected[19]' '81db6ae158a06949fc61e273014dc0f5' 
 3 '' '24000'  
 4 '' '60000'  
 5 '' '12000' 
 6 'plan_id[19]' '15'  
 7 '' ''  
 8 'plan_selected[19]' '81db6ae158a06949fc61e273014dc0f5' 
 9 'promocode' 'May2022'  
 10 'Submit' 'Пересчитать'  
 11 'processor' 'payanyway'  
 12 '' ''  
 13 'continue' 'Продолжить покупки'  
 14 'checkout' 'Оформить заказ'  
 15 'option' 'com_guru'  
 16 'controller' 'guruBuy'  
 17 'task' 'checkout' 
 18 'view' 'test'  
 19 'order_id' '0'  
 20 'action' ''  
 21 '' '2'  
 22 '' '0'  
 23 '' 'Please log-in first!'  
 24 '' '9600.00'  
 25 '' '0'

The elements 0-2 and 6-8 are the same, but the 6-8 are the default values in the form, and the metod “Submit” is not working properly, always the user find, that he have to pay for default values of the form.

At the old site this code have another result:

0 'plan_id[19]' '3' 
1 'plan_selected[19]' '811ca521aeaf79afd1782d7f018429d0' 
2 '' '24000' 
3 '' '60000' 
4 '' '12000' 
5 'promocode' 'May2022' 
6 'Submit' 'Пересчитать' 
7 'processor' 'payanyway' 
8 'continue' 'Продолжить покупки' 
9 'checkout' 'Оформить заказ' 
10 'option' 'com_guru' 
11 'controller' 'guruBuy' 
12 'task' 'checkout' 
13 'view' 'test' 
14 'order_id' '0' 
15 'action' '' 
16 '' '2'
17 '' '0' 
18 '' 'Please log-in first!' 
19 '' '24000.00' 
20 '' '0'

I make this hack to changhe form.elements:

I can’t insert the code, only the picture…

And now it working properly. But I sure, it is wrong way. Could anybody tell me the right way?

How to apply a Javascript animation function to multiple images in for loop?

I am trying to apply animation to all of the images created in a for loop, but none of the images created in the for loop are showing any animation, I have tried in multiple ways such as using forEach and a regular for loop paired with querySelectorAll. When I tried to fix my problem with those methods, it either only affected the first image from the for loop or nothing happened at all.

Essentially, what I want is to make it so the 10 images created prior in a for loop can have the same animation as the first image that is being animated across the screen. I also want the other images created to have the same functionality as the first image, when the image is clicked, the click counter should also work similar to that of the first image. Please help.

Full code is linked here: https://code.sololearn.com/Wwdw59oenFqB

<!DOCTYPE html>
<html lang="en">
  <head>
      <title>Test</title>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <style>
        body {
        zoom: 25%
        }
          .circle {
            display: block;
            background: black;
            border-radius: 100%;
            height: 100px;
            width: 100px;

            background: radial-gradient(circle at center,#31f541, #000);
          }
          .container {
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
          }
          .circle-image{
              z-index: 2;
              position: absolute;
              margin-left: 50%;
              margin-top: 50vh;
              border-radius: 50%;
          }

      </style>
  </head>
  <body>

      <div class="container">
          <img id = "firstImage" style = "height: 1000px; width: 1000px;" onclick = "change(); clickCounter(); animate(); saveData();"class="circle-image" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAIQAWQMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAGAAIDBAUBB//EADsQAAIBAwMCAwYFAgMJAQAAAAECAwAEEQUSITFBBhNRIlJhcYGRFDJCofDB0SMzsRUkJVNiY5Ki4Qf/xAAYAQADAQE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c7/AGhjAIqT8RH/ANVE2HiUIwcjrU+4AVDHx0p7da5ygS6BeQeQIyR5oOMN0xT/ABLJbyQJAux5GOSVbO2hV8gcVbsruNxtc4ZabfDYX4lYSAxkHC+yDWxps8i7AwXaFOD9qyIYDv3BsjpkelXYUdME42AYqiYrG6neb9Ri3jlDkEfGiLSbgOVXZtLHAz3rFg038TMHcDg8UV6ZB/iKoHC0v1+h3zw1BwowR8eaYVjyGxjmpSVK8fSoZVLDk8+oqgguMn0x9qZti979/wD5UYk8olXBYetP/FL6j7GgE8pj0qUD8pqOazlTOUOMelejDT4wv5ail0uJ/wBPwxS9A6eayo3OQRUJgdIwQpJIzmvRJdAifkqMH4VFF4e8sso8t0I9jd1X4fGlcMZVgBtf3Vn5cm0lCeR8KJLOeaeZCkDbCc4PpW7e+GYruzeJAqyFPZOOAan0eNR5azKsMxGDGR3HBx602NIGpsWnJOm1WiIY84AohtYliVuPbJ5NPCqFXaOi8/OuIecY6E5opf6Bseo9nA64610bcZPYenNNBw23BIHHSub8MQM/amARTRK+SwBPc5HpUP4KP3D9hVmTjlenyrm0f82sYqsxCkjt/enI29sN6fz/AFpUqBjp/Lk9hxXUUEtSpVjD04OMnjpUnBxkClSogOljj5iuRHJI90ZFcpVjDixJJPf+tMYYVcfqzmlSrBHSLjjPcD7ml+HT1NKlWCf/2Q==">
          <img id = "secondImage" style = "height: 1000px; width: 1000px;" onclick = "animate();"class="circle-image" src="https://en.meming.world/images/en/thumb/e/e2/Crying_Cat_screaming.jpg/300px-Crying_Cat_screaming.jpg">
          <p style = "transform: scale(10, 10);"id = "clicker">Kitten has been pat: <a id="clickCounter">0</a> times in <a id = "timeCounter">0</a> seconds</p>
          <figure class="circle"></figure>

      </div>
      <button onclick = "saveData();"id = "saveButton">Load progress</button>
  <script>
const cats = [];
    for(i = 0; i < 10; i++){
        var img = document.createElement("img");
        img.setAttribute("src", "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgk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= "catSwarm"
        img.addEventListener('click', function handleClick(event) {
        change(); clickCounter();


});
img.addEventListener('load', function handleClick(event) {

    })

        document.body.appendChild(img);
        cats.push(img)

}

      let clicks = 0;
function clickCounter() {
  clicks += 1;
  document.getElementById("clickCounter").innerHTML = clicks;
  if (clicks != 10) {

  }
  else {
      alert("Kitten has been pet 10 times")
  }
};
let time = 0;

function timeCounter() {
    time+=1
    document.getElementById("timeCounter").innerHTML = time;
    setTimeout(timeCounter, 1000)
    if(time != 10) {

    }
    else{
        setTimeout(function() {
        alert ("Kitten has been pet " + clicks + " times in " + time + " seconds" + " with a whopping pats per second rate of " + clicks/time + "!")
    }, 10);
}}
timeCounter();

      function change() {
          if(document.getElementById("firstImage").style.src = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAIQAWQMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAGAAIDBAUBB//EADsQAAIBAwMCAwYFAgMJAQAAAAECAwAEEQUSITFBBhNRIlJhcYGRFDJCofDB0SMzsRUkJVNiY5Ki4Qf/xAAYAQADAQEAAAAAAAAAAAAAAAABAgMABP/EAB8RAAMBAAMBAQEBAQAAAAAAAAABAhEDEiExQTJRBP/aAAwDAQACEQMRAD8AMAM1V1S7/BRI7ZwzbeKu45rJ8VRFtIaRR/lOrfTp/Wov4VlbSLlpeRXEWVkBPcHgj6VaAyOtCen3BghWd2AJ5OWxgVonUHaPzbJtxUZaPggj1GKDrqtKPj1+G4qmuiM9axG1SdUG4AEruxVaLVLozZ39DgCpP/olGXBRtahothqSBL+yguF/7iA4+vah+f8A/N/DLs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XBYetP/FL6j7GgE8pj0qUD8pqOazlTOUOMelejDT4wv5ail0uJ/wBPwxS9A6eayo3OQRUJgdIwQpJIzmvRJdAifkqMH4VFF4e8sso8t0I9jd1X4fGlcMZVgBtf3Vn5cm0lCeR8KJLOeaeZCkDbCc4PpW7e+GYruzeJAqyFPZOOAan0eNR5azKsMxGDGR3HBx602NIGpsWnJOm1WiIY84AohtYliVuPbJ5NPCqFXaOi8/OuIecY6E5opf6Bseo9nA64610bcZPYenNNBw23BIHHSub8MQM/amARTRK+SwBPc5HpUP4KP3D9hVmTjlenyrm0f82sYqsxCkjt/enI29sN6fz/AFpUqBjp/Lk9hxXUUEtSpVjD04OMnjpUnBxkClSogOljj5iuRHJI90ZFcpVjDixJJPf+tMYYVcfqzmlSrBHSLjjPcD7ml+HT1NKlWCf/2Q==") {
              document.getElementById("firstImage").src = "https://en.meming.world/images/en/thumb/e/e2/Crying_Cat_screaming.jpg/300px-Crying_Cat_screaming.jpg";
          }
          else {document.getElementById("firstImage").style.src = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAIQAWQMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAGAAIDBAUBB//EADsQAAIBAwMCAwYFAgMJAQAAAAECAwAEEQUSITFBBhNRIlJhcYGRFDJCofDB0SMzsRUkJVNiY5Ki4Qf/xAAYAQADAQEAAAAAAAAAAAAAAAABAgMABP/EAB8RAAMBAAMBAQEBAQAAAAAAAAABAhEDEiExQTJRBP/aAAwDAQACEQMRAD8AMAM1V1S7/BRI7ZwzbeKu45rJ8VRFtIaRR/lOrfT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wXaFOD9qyIYDv3BsjpkelXYUdME42AYqiYrG6neb9Ri3jlDkEfGiLSbgOVXZtLHAz3rFg038TMHcDg8UV6ZB/iKoHC0v1+h3zw1BwowR8eaYVjyGxjmpSVK8fSoZVLDk8+oqgguMn0x9qZti979/wD5UYk8olXBYetP/FL6j7GgE8pj0qUD8pqOazlTOUOMelejDT4wv5ail0uJ/wBPwxS9A6eayo3OQRUJgdIwQpJIzmvRJdAifkqMH4VFF4e8sso8t0I9jd1X4fGlcMZVgBtf3Vn5cm0lCeR8KJLOeaeZCkDbCc4PpW7e+GYruzeJAqyFPZOOAan0eNR5azKsMxGDGR3HBx602NIGpsWnJOm1WiIY84AohtYliVuPbJ5NPCqFXaOi8/OuIecY6E5opf6Bseo9nA64610bcZPYenNNBw23BIHHSub8MQM/amARTRK+SwBPc5HpUP4KP3D9hVmTjlenyrm0f82sYqsxCkjt/enI29sN6fz/AFpUqBjp/Lk9hxXUUEtSpVjD04OMnjpUnBxkClSogOljj5iuRHJI90ZFcpVjDixJJPf+tMYYVcfqzmlSrBHSLjjPcD7ml+HT1NKlWCf/2Q=="> {

          }
      }}
      function saveData() {

  if (typeof(Storage) !== "undefined") {
    if (localStorage.clickcount) {
      localStorage.clickcount = Number(localStorage.clickcount)+1;
    } else {
      localStorage.clickcount = 1;
    }
    document.querySelector("p").innerText = "Kitten has been pat: " + localStorage.clickcount + " times in " + time + " seconds";
  }

      }
const fps = 25;

let image = document.querySelector("img");
let angle = Math.PI / 2;
//store the previous time the animate function last fired
let prevTimeArg;

function animate(currentTimeParam){


    if (prevTimeArg != null) {
        angle += (currentTimeParam - prevTimeArg) * 0.004;
    }
    // Setting the previous time to the time the function currently fires
    prevTimeArg = currentTimeParam ;
    image.style.top = (Math.tan(angle) * 150) + "px";
    image.style.left = (Math.tan(angle) * 150) + "px";
    image.style.height = (Math.cos(angle) * 1000) + "px";
    image.style.width = (Math.cos(angle) * 1000) + "px";


setTimeout(() => {
    requestAnimationFrame(currentTime => animate(currentTime));
}, 0 / fps)}

    for (i = 0; i < cats.length; i++) {
        window.requestAnimationFrame(animate);
    }



  </script>
  </body>
</html>

Thank you in advance.

Sending images from React never received by backend [duplicate]

I’m trying to send images from react to my API but they never get received. This is my code where I make the request from React:

const [files, setFiles] = useState([])
const onSubmit = data => {
  data.pictures = files
  try {
    setLoading(true)
    postProduct(data) //send petition
  } catch (error) {
    setLoading(false)
  }
}

PostProduct:

    const postProduct = async product => { 
        try {
            const dataOnLs = localStorage.getItem('cmtjs')
            const formData = new FormData()

            for (let i = 0; i < product.pictures; i++) {
                formData.append(`files[${i}]`, product.pictures[i])
            }
            const config = {
                headers: {
                    "Content-Type": "application/json",
                    apiKey: dataOnLs
                },
                files: formData        
            } 

            const { data } = await axiosClient.post(`/products`, product, config )
            setProducts([...products.products.docs, data])

        } catch (error) {
        }
    }

But on the server side I never receive files, in the body I have the data of the form and “pictures” that contains the array of images but the server does not take it as a file so it does not process it since it validates if(req.files) contains something and since it is not like that, it answers me with an error:

  body: {
    barCode: '33',
    idProduct: '12',
    name: 'Peishion',
    purchasePrice: '2',
    salePrice: '3',
    presentation: 'KILOGRAM',
    category: '62625e6d8cbba0c8f0734257',
    provider: '6271a32082193f4b88e292f0',
    desc: 'adaaasas',
    pictures: [ [Object], [Object] ]
  },

I also tried changing in axios headers to:

“Content-Type”: “multipart/form-data”,

But i have the same problem.

why owl carousel is effecting mobile view of my browser

Please check my site:
https://papantoniou.vercel.app/

When I view the webpage without adding our services section and our news section carousel in a mobile view from my desktop browser by adding display: none; to services_panel and news_section then the whole page looks good as expected.

But when I remove the display: none; from both sections then I have an infinite vertical scroll in my browser. I don’t know why? please help me.

The same issue comes if I use container-fluid instead of the container inside individual section “get infinite vertical scroll”

Add back and forward functionality to my JavaScript App

How can I add back and forward functionality to my JavaScript App?

I have a Javascript application with a button and two search inputs. The results returned when they are clicked have urls and take me from one page to another. I can’t go back to the previous page or forward to the back page.

I tried using history.push, but it breaks my whole code and nothing gets returned.

history.pushState(data, null, url);

window.addEventListener('popstate', function() {

});

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/styles.css">

</head>
<body>
    <div id="wrap">
<button id="showResult">View Result</button>
<input type="search" id="input" placeholder="Search">
    </div>
<div id="myData"></div>

<script> 

const displayItem = (item, i) => {
  const pre_data = document.createElement('pre');
  const dt_data = document.createElement('dt');
  dt_data.textContent = item;
  pre_data.appendChild(dt_data);
  if (i !== 'undefined') {
    const dd_data = document.createElement('dd')

    if (item == "url") {
      const click = document.createElement('a');
      click.textContent = i;
      click.setAttribute('href', '#')
      click.addEventListener('click', function(e) {
        fetchData(e.target.innerHTML)
      });
      dd_data.appendChild(click);

    } else {
      dd_data.textContent = i;

    }

    pre_data.appendChild(dd_data);

    pre_data.appendChild(dd_data);
  }
  return pre_data;
}
const formatResult = (obj) =>{
  const dl = document.createElement('dl');


  for(let k in obj) {
    if(typeof obj[k]=== "object"  ){
      dl.appendChild(displayItem(k))
      
    } else {
      dl.appendChild(displayItem(k, obj[k]))
      
    }}

 return dl;

}
function fetchData(url){
 
  fetch(url)
.then((res) => (res.ok ? res.json() : Promise.reject(res)))
.then((data) => {
     myData.append(formatResult(data))
    }
})
.catch(console.error);
}

history.pushState(data, null, url);
window.addEventListener('popstate', function() {
});

const showResult=document.getElementById("showResult");

catalog.addEventListener("onclick",  fetchData(`{realurl here}`));

const input = document.getElementById("input");

input.addEventListener("change", (event) =>
  fetchData(`realurl here`/${event.target.value}`)
);

</script>

</body>

</html> 

How can I get the back and forward buttons to start working and taking me to the previous page visited?

Sort a string in Javascript

I have a string like the following. The string contains words which contain a number from 0 to 9 in them The number is the position they must have in the resulting string.
If the string is empty, the result will be an empty string

Example: “en5 4terremoto NAS1A regi2stró L0a M6arte u3n”

Resultado:

 "L0a NAS1A regi2stró u3n 4terremoto en5 M6arte"

how to go through the chain and order it, taking into account the number of each word?

Until now, I applied the split method to the original chain to separate them.

const mensaje = 'en5 4terremoto NAS1A regi2stró L0a M6arte u3n';

const arr = mensaje.split(' ');
console.log(arr);

result

I appreciate your help

using functions or classes to create multiple prime spirals

Im trying to create several prime spirals, after inspiration from Dan Shiffmans coding challenge: https://www.youtube.com/watch?v=a35KWEjRvc0&t=716s&ab_channel=TheCodingTrain

I want the spirals to overlap each other, with a diffrent color and a offset in the starting point of the prime number sequence, to give each spiral a diffrent look.
I would love to use OOP to solve this, but i cant get it to work with functions even, only
one of the spirals is drawn.

I thought it could have something to do with the noLoop function , but removing it does not help.

And if you like the subject i can really recommend this numberphile video, going indepth on prime numbers:

// https://thecodingtrain.com/CodingChallenges/167-prime-spiral.html
// https://youtu.be/a35KWEjRvc0

let x, y;
let step = 1;
let stepSize = 20;
let numSteps = 1;
let state = 0;
let turnCounter = 1;
let totalSteps;
let offset = 0;

function isPrime(value) {
  if (value == 1) return false;
  for (let i = 2; i <= sqrt(value); i++) {
    if (value % i == 0) {
      return false;
    }
  }
  return true;
}

function setup() {
  createCanvas(500, 500);

  const cols = width / stepSize;
  const rows = height / stepSize;
  totalSteps = cols * rows;

  x = width / 2;
  y = height / 2;
  background(0);
}

function draw() {

  primeSpiral(20, 1)
  primeSpiral(30, 200)
  noStroke();
}


function primeSpiral(offset, color){
  if (!isPrime(step+offset)) {
    //might put something here

  } else {
    let r = stepSize * 0.5;
    fill(color, 99, 164);
    push();
    translate(x, y);
    rotate(-PI / 4);
    triangle(-r, +r, 0, -r, +r, +r);
    pop();
  }

  switch (state) {
    case 0:
      x += stepSize;
      break;
    case 1:
      y -= stepSize;
      break;
    case 2:
      x -= stepSize;
      break;
    case 3:
      y += stepSize;
      break;
  }

  if (step % numSteps == 0) {
    state = (state + 1) % 4;
    turnCounter++;
    if (turnCounter % 2 == 0) {
      numSteps++;
    }
  }
  step++;

  if (step > totalSteps) {
    noLoop();
  }
}

How to determine the location of the deno script?

Let’s say I issue the following command:

deno run --allow-read /scripts/where-am-i.ts

What would need to be inside where-am-i.ts for it to output:

/scripts

I’ve tried:

console.log(Deno.cwd());

which prints the directory the script was called from (/ in this example).

I have also tried:

console.log(Deno.execPath());

which prints the location of the deno binary (~/.cargo/bin/deno for me).

Manage notification flutter or javascript?

I’m building a messaging APP for Android and IOS with flutter and I want to manage notifications to be high stander notifications, for exemple they should :
open a specific page
show specific information
can be grouped for the same sender
etc…

My question is: it can be done with only flutter or do I need javascript or any other language to manage it very will ?

await CheckBox[0].click() cannot read properties of undefined (reading ‘click’)

 const CheckBox = await DiscordPage.$x('//*[@id="app-mount"]/div[2]/div/div/div/form/div/div/div[5]/label/input')
        const SubmitButton = await DiscordPage.$x('//*[@id="app-mount"]/div[2]/div/div/div/form/div/div/div[7]/button')
        await Date[0].click() 
        await Date[0].type("May") 
        await Month[0].click() 
        await Month[0].type("5") 
        await Year[0].click() 
        await Year[0].type("2000") 
        await EmailInput.click()
        await EmailInput.type(Email)
        await UsernameInput.click()
        await UsernameInput.type(tokensname)
        await PasswordInput.click()
        await PasswordInput.type(`${tokensname}25`)
        
        await sleep(3000)
        await CheckBox[0].click()
        await SubmitButton[0].click()

sometimes await CheckBox[0].click() Works And Sometimes await CheckBox[0].click()
i Get an error ^
TypeError: Cannot read properties of undefined (reading ‘click’)
anyone know how to solve this?

Automatically trigger an OnClick event of a specific component in React

I’m a beginner to React and Javascript and I’m attempting to create Minesweeper in React from scratch. I’ve run into an issue where I want to replicate the functionality of Minesweeper where if you click a tile with zero mines around it, the surrounding tiles will automatically reveal themselves. However, I’m having trouble figuring out how to do that. My instinct is to grab the surrounding tiles by an id, and somehow manually trigger the OnClick event, but as far as I’m aware my Tile component has no knowledge of other Tile components and thus no way of accessing them. And I don’t see how I could do it from my Board component. Any advice would be greatly appreciated!

Board Component:

class Board extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            height: 8,
            width: 8,
            num_mines: 10
        }
        game_logic.initalizeGame(8,8,10);
        game_logic.createGame();
    }

    render() {
        var all_tiles = [];
        for (var i = 0; i < this.state.height; i++) {
            var row_tiles = [];
            for (var j = 0; j < this.state.width; j++) {
                row_tiles.push(<Tile key={'Tile ' + (i*this.state.height + j)} value={game_logic.tile_values[i][j]} />)
            }
            all_tiles[i] = row_tiles;
        }

        return (
            <div>
                {all_tiles.map((value, index) => {
                    return <div key={'Row ' + index}>{value}</div>
                })} 
            </div>
        )
    }
}

export default Board;

Tile Component:

class Tile extends React.Component {

    
    constructor(props) {
        super(props);
        this.state = {
            imgSrc: null,
            imgAlt: '',
            value: '',
        };
    }

    tileClick = (e) => {
        //left click: unveil tile
        if (e.type === "click" && this.state.imgAlt === '') {
            if (this.props.value < 0) {
                this.setState({value: '', imgSrc: mine, imgAlt: "mine"});
            }
            else {
                this.setState({value: this.props.value})
                if (this.props.value === 0) {
                    //automatically left click all 8 surrounding tiles
                }
            }
        }
        //right click: mark or unmark tile
        else if (e.type === "contextmenu") {
            e.preventDefault();
            if (this.state.value === '' && this.state.imgAlt !== "mine") {
                if (this.state.imgAlt !== '') {
                    this.setState({imgSrc: null, imgAlt: ''});
                }
                else {
                    this.setState({imgSrc: flag, imgAlt: "flag"});
                }
            }
        }
    }
    
    render() {
        return (
            <button 
                className="tile" 
                onClick={this.tileClick} onContextMenu={this.tileClick}>
                    <img src={this.state.imgSrc} alt={this.state.imgAlt} />
                    {this.state.value}
            </button>
        );
    }
}

export default Tile;

Im having trouble hitting my routes in insomnia–but defined routes don’t crash my server

Testing my routes in insomnia and cant trouble shoot why they wont hit.–
controller–

const Sequelize = require('sequelize')

const GetStreamer = async (req, res) => {
    try{
        const streamers = await Streamer.findAll()
        res.send(streamers)
    } catch (error){
        throw error
    }
}

module.exports = {
    GetStreamer
}

router–

const controller = require('../controllers/StreamerController')

Router.get('/streamers', controller.GetStreamer)

module.exports = Router

appRouter–

const StreamerRouter = require('./StreamerRouter')

app.use('/streamers', StreamerRouter)

module.exports = router


server.js–

const express = require('express')
const cors = require('cors')

const app = express()



const PORT = process.env.PORT || 3001

// Middleware
app.use(cors())
app.use(express.json())




// Routes Go Here

app.get('/', (req, res) => res.json({ message: 'wtf'}))

app.listen(PORT, () => console.log(`Server Started On Port: ${PORT} boogers`))

this is a pern stack app and the normal dependancies are installed and like i said the server seems fine but insomnia and testing the route in a browser doesnt work.

i want to update a number in mongodb but showing bad request

i was trying to update a single element(which is a number)which is stored in mongodb .
here is the request i sent to the db:

const handleDelivered = (num) =>{

const total =  service.quantity;

const final = parseInt(total) + num;

console.log(total,final);
const url = `http://localhost:5000/services/${idOfService}`;
fetch(url,{
  method :'PUT',
  headers :{
    'content-type': 'application/json',
  },
  body : JSON.stringify(final)
})
.then(res => res.json())
.then(product =>{
  console.log(product);
})

}

the data stored inside mongodb is object of array. to execute the operation i tried to build an api with express .
here is the code for the api

app.put(‘/services/:id’, async(req,res)=>{

const id = req.params.id;

const filter = {_id : ObjectId(id)};

const options = { upsert: true };

const updatedData = req.body;

const updateDoc = {

   $set: {
                            
    quantity : updatedData.quantity,
                        
},
                      

};

const result = await serviceCollection.updateOne(filter, updateDoc, options);

res.send(result);

});

whenever i click on the button to update it shows an error saying PUT(link)400 (bad request)
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0