Why does Fetch Promise deliver?

I’m using strapi in my project, but when I fetch, it gives me promise instead of json

my code :

const [products, setproducts] = useState([]);
    useEffect(() => {
        (async () => {
            try {
                let res = await fetch("http://localhost:1337/api/categories");
                let data = res.json()
                setproducts(data);
                console.log(data)
            }
            catch (err) { alert(err) }
        })();
    }, []);  

The response the Postman gave me has JSON

How can I add an XML page with vike (ssr) to my website?

For my website I use vike for ssr. For SEO, I would like to add a sitemap in XML format. However, vike builds my pages in html format. Is there a way in which I can enter the XML file for SEO?

I tried to access the xml file via the vike router, which did not work. I also had the idea of writing a function in the render folder that returns the xml page and is then called instead of +onRenderHtml when the sitemap is called. But I couldn’t manage that.

Bun: streaming stdout of spawned subprocess to Response without copying

In my Bun backend, am calling a subprocess which returns a (large) json text on its stdout. This should, without changes, returned in the Response.

I am doing it like this:

const tsv2json = Bun.spawn('tsv2json', filename])
const content = await Bun.readableStreamToText(tsv2json.stdout);
return new Response(content, { headers: {'Content-Type': 'application/json' } });

This works, but I think there is unnecessary copying of large strings going on.
I would like it to work like this:

return new Response(tsv2json.stdout, { headers: {'Content-Type': 'application/json' } });

But it does not work; the Response is returned but with no content and subprocess seems to hang.

What am I missing?

To Pivot an Array Of Objects for Cricket Scorecard and get the result as an Array 0f Objects

I have an array of objects which I need to convert to a table (kind of pivoting the data).

I am trying to do is to create a pivot table-style data format from an Array of Objects.

I have the Array data have given below :

var originalArray = [
{BallId: 1,  Overs: 0.1, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 1, Wickets: 0},
{BallId: 2,  Overs: 0.1, BowlerName: "Deepak Chahar",      Runs: 1, Extras: 0, Wickets: 0},
{BallId: 3,  Overs: 0.2, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 4,  Overs: 0.3, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 5,  Overs: 0.4, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 6,  Overs: 0.5, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 1},
{BallId: 7,  Overs: 0.6, BowlerName: "Deepak Chahar",      Runs: 1, Extras: 0, Wickets: 0},
{BallId: 8,  Overs: 1.1, BowlerName: "Tushar Deshpande",   Runs: 4, Extras: 0, Wickets: 0},
{BallId: 9,  Overs: 1.2, BowlerName: "Tushar Deshpande",   Runs: 0, Extras: 0, Wickets: 0},
{BallId: 10, Overs: 1.3, BowlerName: "Tushar Deshpande",   Runs: 4, Extras: 0, Wickets: 0},
{BallId: 11, Overs: 1.4, BowlerName: "Tushar Deshpande",   Runs: 0, Extras: 0, Wickets: 0},
{BallId: 12, Overs: 1.5, BowlerName: "Tushar Deshpande",   Runs: 0, Extras: 0, Wickets: 0},
{BallId: 13, Overs: 1.6, BowlerName: "Tushar Deshpande",   Runs: 1, Extras: 0, Wickets: 0},
{BallId: 14, Overs: 2.1, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 0},
{BallId: 15, Overs: 2.2, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 1, Wickets: 1},
{BallId: 16, Overs: 2.2, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 17, Overs: 2.3, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 0},
{BallId: 18, Overs: 2.4, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 0},
{BallId: 19, Overs: 2.5, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 20, Overs: 2.6, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 1},
{BallId: 21, Overs: 3.1, BowlerName: "Maheesh Theekshana", Runs: 0, Extras: 0, Wickets: 0},
{BallId: 22, Overs: 3.2, BowlerName: "Maheesh Theekshana", Runs: 1, Extras: 0, Wickets: 0},
{BallId: 23, Overs: 3.3, BowlerName: "Maheesh Theekshana", Runs: 0, Extras: 0, Wickets: 0},
{BallId: 24, Overs: 3.4, BowlerName: "Maheesh Theekshana", Runs: 0, Extras: 1, Wickets: 0},
{BallId: 25, Overs: 3.5, BowlerName: "Maheesh Theekshana", Runs: 1, Extras: 0, Wickets: 0},
{BallId: 26, Overs: 3.6, BowlerName: "Maheesh Theekshana", Runs: 1, Extras: 0, Wickets: 0},
{BallId: 27, Overs: 4.1, BowlerName: "Mustafizur Rahman",  Runs: 0, Extras: 0, Wickets: 0},
{BallId: 28, Overs: 4.2, BowlerName: "Mustafizur Rahman",  Runs: 4, Extras: 0, Wickets: 0},
{BallId: 29, Overs: 4.3, BowlerName: "Mustafizur Rahman",  Runs: 0, Extras: 0, Wickets: 1},
{BallId: 30, Overs: 4.4, BowlerName: "Ravindra Jadeja",    Runs: 0, Extras: 0, Wickets: 0},
{BallId: 30, Overs: 4.5, BowlerName: "Ravindra Jadeja",    Runs: 0, Extras: 0, Wickets: 0},
{BallId: 30, Overs: 4.6, BowlerName: "Ravindra Jadeja",    Runs: 0, Extras: 0, Wickets: 1}
];

My Expected Output is Like :

var expectedArray = [
{BowlerName: "Deepak Chahar",                      Overs: 1, Run_1: 1, Run_2: 1, Run_3: 0, Run_4: 0, Run_5: 0, Run_6: 4, Run_7: 1, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 7,  Total_Runs: 7,  Wickets: 1},
{BowlerName: "Tushar Deshpande",                   Overs: 2, Run_1: 4, Run_2: 0, Run_3: 4, Run_4: 0, Run_5: 0, Run_6: 1, Run_7: 0, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 9,  Total_Runs: 16, Wickets: 0},
{BowlerName: "Deepak Chahar",                      Overs: 3, Run_1: 4, Run_2: 1, Run_3: 0, Run_4: 4, Run_5: 4, Run_6: 0, Run_7: 4, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 17, Total_Runs: 33, Wickets: 2},
{BowlerName: "Maheesh Theekshana",                 Overs: 4, Run_1: 0, Run_2: 1, Run_3: 0, Run_4: 1, Run_5: 1, Run_6: 1, Run_7: 0, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 4,  Total_Runs: 37, Wickets: 0},
{BowlerName: "Mustafizur Rahman, Ravindra Jadeja", Overs: 5, Run_1: 0, Run_2: 4, Run_3: 0, Run_4: 0, Run_5: 0, Run_6: 0, Run_7: 0, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 4,  Total_Runs: 50, Wickets: 2}
];

My Expected Output to be in a HTML Table like (Image is for Example Only) :

Sample Image (Cricket Scorecard with Data)

My Expected Output must have :

In the First Over and Third Over, I Have 2 Balls for 1’st over 1’st Ball as an extra, the extra also have to be added in the Runs and Total_Runs of Expected output.

In 3’rd over 2 repeated balls for 2’nd ball, while in the Expected Output have to add it in between the Run_1 to Run_10 column.

The more the extras is there the values between Run_1 to Run_10 columns will increase (as show in the image).

If a Over is shared by 2 players, the Expected Output BowlerName Column have to contain 2 players data (as mentioned in the 5’th Over of Expected Output).

Why does my console keep bringing up a ‘method (405) not allowed’ in my deployed app?

I recently developed a weather prediction app that uses OpenAI’s gpt-3.5-turbo.
When I run it in my local environment, it works perfectly, but when I deploy to either Vercel, Netlify, or Cloudflare, it does not work. It prints a method (405) not allowed in the console.

This is my HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Weather Predictor</title>
    <style> 
    body {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh; /* Set the height of the body to 100% of the viewport height */
            margin-top: 150px; 
            margin-bottom: 150px;
            padding: 0; /* Remove default padding */
            flex-direction: column; /* Stack elements vertically */
            text-align: center; /* Center text horizontally */
            background-image: url('https://imgur.com/a/Z3uSG4q');
            background-color: #f0f0f0;
            background-size: cover; /* Cover the entire viewport */
            background-repeat: no-repeat; /* Do not repeat the image */
        }

        form {
            width: 400px; /* Set the width of the form */
            background-color: rgba(255, 255, 255, 0.8); /* Add a semi-transparent white background to the form */
            padding: 20px;
            border-radius: 10px; /* Add rounded corners */
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Add a shadow effect */
        }

        input[type="submit"] {
            background-color: #4CAF50; /* Green background color */
            color: white; /* White text color */
            padding: 5px 10px; /* Padding for the button */
            font-size: 16px; /* Font size of the text */
            border: none; /* Remove the border */
            border-radius: 5px; /* Add rounded corners */
            cursor: pointer; /* Change cursor to pointer on hover */
        }

        /* Change styles on hover */
        input[type="submit"]:hover {
            background-color: #45a049; /* Darker green on hover */
        }

        /* Add any other CSS styles here */
    </style>
</head>
<body>
    <h1>Weather Predictor</h1>
    <form id="predictionForm" method="post" action="/">
        <label for="date">Date</label><br>
        <input type="text" id="date" name="date"><br><br>
        <input type="submit" value="Predict Match">
    </form><br>
    <div id="predictionResult"></div>
    <script>
        document.getElementById("predictionForm").addEventListener("submit", function(event) {
            event.preventDefault(); // Prevent default form submission

            var date = document.getElementById("date").value;

            var jsonData = {
                "date": date,
            };

            fetch('/', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(jsonData)
            })
            .then(response => response.json())
            .then(data => {
                displayPrediction(data.prediction);
            })
            .catch(error => {
                console.error('Error:', error);
            });
        });

        function displayPrediction(prediction) {
            var predictionResultElement = document.getElementById("predictionResult");
            predictionResultElement.innerHTML = ""; // Clear previous content
            var predictionText = document.createTextNode("Prediction: " + prediction);
            predictionResultElement.appendChild(predictionText);
        }
    </script>


</body>
</html>

This is my Python:

from http.server import BaseHTTPRequestHandler, HTTPServer
import json
from openai import OpenAI

# Initialize OpenAI client
client = OpenAI()

class RequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == '/favicon.ico':
            self.send_response(404)
            self.end_headers()
            return

        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

        with open('index.html', 'r') as file:
            html_content = file.read()

        self.wfile.write(html_content.encode('utf-8'))

    def do_POST(self):
        content_length = int(self.headers['Content-Length'])
        post_data = self.rfile.read(content_length)

        try:
            data = json.loads(post_data.decode('utf-8'))
            print("Received data:", data)

            date = data.get('date', '')

            if not date:
                prediction = "Please enter date."
            else:
                response = client.chat.completions.create(
                    model="gpt-3.5-turbo",
                    messages=[
                        {
                            "role": "system",
                            "content": "You will be provided with a date. You are to predict the weather in Lagos, Nigeria for that date. You should tell the maximum and minimum temperatures for that day and if it will rain or not. Don't talk too much, just be straight to the point and say the predicted weather"
                        },
                        {
                            "role": "user",
                            "content": f"{date}"
                        }
                    ],
                    temperature=0.1,
                    max_tokens=100,
                    top_p=1
                )
                prediction = response.choices[0].message.content

        except Exception as e:
            print("Error:", e)
            prediction = "Error occurred while generating prediction."

        # Ensure prediction is serializable
        if not isinstance(prediction, str):
            prediction = str(prediction)

        self.send_response(200)
        self.send_header('Content-type', 'application/json')
        self.end_headers()

        response_data = json.dumps({"prediction": prediction})
        self.wfile.write(response_data.encode('utf-8'))

def run(server_class=HTTPServer, handler_class=RequestHandler, port=8080):
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    print('Starting server...')
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    print('Stopping server...')

if __name__ == '__main__':
    run()

In Javascript are there non functional reasons to call removeEventHandler?

Suppose I added an event listener to some element on the DOM,
Will leaving it attached when the DOM element is destroyed cause some sort of memory leak even assuming that the JavaScript engine is doing its work properly / to the best of its ability ?

So basically – apart from the functional reasons of “I don’t want this event handler to run again” Do I need to call removeEventHandler ?

There is an internal server error when sending an email

Internal server error occurs when a verification e mail sent.

here verification ,

// Send Verification Email
const sendVerificationEmail = asyncHandler(async (req, res) => {
  const user = await User.findById(req.user._id);

  if (!user) {
    res.status(404);
    throw new Error("User not found");
  }

  if (user.isVerified) {
    res.status(400);
    throw new Error("User already verified");
  }

  // Delete Token if it exists in DB
  let token = await Token.findOne({ userId: user._id });
  if (token) {
    await token.deleteOne();
  }

  //   Create Verification Token and Save
  const verificationToken = crypto.randomBytes(32).toString("hex") + user._id;
  console.log(verificationToken);

  // Hash token and save
  const hashedToken = hashToken(verificationToken);
  await new Token({
    userId: user._id,
    vToken: hashedToken,
    createdAt: Date.now(),
    expiresAt: Date.now() + 60 * (60 * 1000), // 60mins
  }).save();

  // Construct Verification URL
  const verificationUrl = `${process.env.FRONTEND_URL}/verify/${verificationToken}`;
  //Send  Verification email

  const subject = "Verify Your Account - PrimeLodge";
  const send_to = user.email;
  const sent_from = process.env.EMAIL_USER;
  const reply_to = "[email protected]";
  const template = "verifyEmail";
  const name = user.name;
  const link = verificationUrl;

  try {
    await sendEmail(
      subject,
      send_to,
      sent_from,
      reply_to,
      template,
      name,
      link
    );
    res.status(200).json({ message: "Email Sent" });
  } catch (error) {
    console.error(error); // Log the error
    res.status(500).json({ error: "Email not sent, please try again" });
  }


});

I want to send an verification email to new user, when I clicked [enter enter image description here can anyone help to fix this . Thank you

POST 502 Gateway error – Plugin keeps loading

Within the WordPress website there is the plugin Easy Appointments. This plugin always worked but since a couple of weeks to a month the pages of the plugin keep loading.

When looking at the back-end (console log) there is a error which probably causes this. It is the POST (link to website and link to .php) 502 (Bad Gateway) and especially it is within this part of the code:

                    try {
                        **r.send(i.hasContent && i.data || null)**
                    } 
  • I have tried changing the back-end but that doesn`t work. Can you guys see where somethings went wrong?

  • I have tried looking within the back-end for why this error accures but nothing changed within the code for the past years so I don`t know why this happens.

  • I have tried some resolutions of other Stack Overflow questions but those didn`t work.

If you need more information regarding this problem, please let me know and I will share it.

Thank you in advance

problem in my codes, not working in live server

the code in my test server is not working on the live server, i don’t know how to solve this, i’m new developer.

i tried to use ajax for the button to not reload when clicking a button, and it work to my test server but when i transfer it to live server it’s not working.

this is my script code

// Function to handle leave application rejection or cancellation
function handleLeaveAction(url, statusValue, message, reload, statusText, statusClass) {
  $.ajax({
    type: 'PUT',
    url: url,
    data: {
      status: statusValue,
      _token: $('meta[name="csrf-token"]').attr('content')
    },
    success: function(response) {
      // Handle successful action
      console.log(`Leave application action executed successfully`);
      // Update the page with the new data
      $('#element-to-update').html(response.new_data);
      if (statusText) {
        $('#element-to-update').append(`<p class="${statusClass}">${statusText}</p>`);
      }
      if (reload) {
        location.reload();
      }
    },
    error: function(xhr, status, error) {
      // Handle error
      console.log(`Error executing leave application action`);
    }
  });
}

// Event listener for approve button click
$(document).on('click', '.s-approve-button', function(e) {
  e.preventDefault();
  const leaveApplicationId = $(this).data('leave-application-id')
  const url = $(this).data('url')

  if (confirm('Are you sure you want to approve this leave application?')){
    handleLeaveApproval(leaveApplicationId, url);
  }
});

// Event listener for reject or cancel button click
$(document).on('click', '.s-reject-button, .s-cancel-button', function(e) {
  e.preventDefault();
  const url = $(this).data('url')
  const statusValue = $(this).data('status-value')
  const message = $(this).data('message') || `Are you sure you want to ${$(this).data('leave-type')} this leave application?`;
  const reload = $(this).data('reload') || false;
  const statusText = $(this).data('status-text')
  const statusClass = $(this).data('status-class')

  if (confirm(message)){
    handleLeaveAction(url, statusValue, message, reload, statusText, statusClass);
  }
});

Asymmetric key encryption and decryption using js and python

I am trying to include asymmetric encryption . The logic is:
Python (flask) generates public and private key. the public key is sent to js. js encrypts the message and sends it back to the python flask backend. the backend now decrypts the key.
The problem is this isn’t working. The key length should be equal to ciphertext is the error I am recieving.

#python code:

from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric import padding
from Crypto.Cipher import PKCS1_v1_5

def encrypt(public_key, plaintext):
# Deserialize the public key
public_key_obj = serialization.load_pem_public_key(public_key)

# Encrypt the plaintext using the public key
ciphertext = public_key_obj.encrypt(
    plaintext.encode(),
    padding.OAEP(
        mgf=padding.MGF1(algorithm=hashes.SHA256()),
        algorithm=hashes.SHA256(),
        label=None
    )
)
return ciphertext

def decrypt(private_key, ciphertext):
# Load the private key
private_key_obj = serialization.load_pem_private_key(private_key, password=None)

# Initialize the cipher with the private key
cipher = PKCS1_v1_5.new(private_key_obj)

# Decrypt the ciphertext
decrypted_data = cipher.decrypt(ciphertext, None)

return decrypted_data.decode('utf-8')

def generate_keypair():
# Generate RSA key pair
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048
)
public_key = private_key.public_key()

# Serialize private key to PEM format
pem_private_key = private_key.private_bytes(
    encoding=serialization.Encoding.PEM,
    format=serialization.PrivateFormat.PKCS8,
    encryption_algorithm=serialization.NoEncryption()
)

# Serialize public key to PEM format
pem_public_key = public_key.public_bytes(
    encoding=serialization.Encoding.PEM,
    format=serialization.PublicFormat.SubjectPublicKeyInfo
)

return pem_private_key, pem_public_key

if __name__ == '__main__':

private_key, public_key = generate_keypair()

# Encrypted data received from JavaScript
encrypted_data_from_js = "..."  # Insert the encrypted data received from JavaScript

# Decode the base64 encoded encrypted data
encrypted_data = base64.b64decode(encrypted_data_from_js)

# Decrypt the encrypted data
decrypted_data = decrypt(private_key, encrypted_data)

print("Decrypted message:", decrypted_data)

#flask code:

@app.route('/login', methods=['GET', 'POST'])
def login():
private_key,public_key = generate_keypair()
print(private_key,":",public_key)
form = LoginForm()
if session.get('username'):
return redirect(url_for('index'))
if request.method=='GET':
return render_template('login.html', error_message='Not Authorised',public_key=public_key)
if form.validate_on_submit():
username = form.username.data
encrpassword = form.password.data
print(f"{username}:{encrpassword}")
password = decrypt(private_key=private_key, ciphertext=encrpassword.encode())
print(f'username {username} password {password}')
access, role = get_user_access_privilege(username)

//JS code:

<script>
    function encryptAndSubmit() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        var secretKey = "{{ public_key }}"; // Public key from Python
        encryptor.setPublicKey(secretKey);
        var encryptedPassword = encryptor.encrypt(password);
        // Update the password field with the encrypted password
        document.getElementById("password").value = encryptedPassword;
        alert(secretKey);
        document.getElementById("LoginForm").submit();
    }
    // Call the function when the form is submitted
    document.getElementById("LoginForm").addEventListener("submit", encryptAndSubmit);
    
</script>

Pivot An Array Of Objects in JavaScript then get the result as an Array 0f Objects [closed]

I have an array of objects which I need to convert to a table (kind of pivoting the data).

I am trying to do is to create a pivot table-style data format from an Array of Objects.

I have the Array data have given below :

var originalArray = [
{BallId: 1,  Overs: 0.1, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 1, Wickets: 0},
{BallId: 2,  Overs: 0.1, BowlerName: "Deepak Chahar",      Runs: 1, Extras: 0, Wickets: 0},
{BallId: 3,  Overs: 0.2, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 4,  Overs: 0.3, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 5,  Overs: 0.4, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 6,  Overs: 0.5, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 1},
{BallId: 7,  Overs: 0.6, BowlerName: "Deepak Chahar",      Runs: 1, Extras: 0, Wickets: 0},
{BallId: 8,  Overs: 1.1, BowlerName: "Tushar Deshpande",   Runs: 4, Extras: 0, Wickets: 0},
{BallId: 9,  Overs: 1.2, BowlerName: "Tushar Deshpande",   Runs: 0, Extras: 0, Wickets: 0},
{BallId: 10, Overs: 1.3, BowlerName: "Tushar Deshpande",   Runs: 4, Extras: 0, Wickets: 0},
{BallId: 11, Overs: 1.4, BowlerName: "Tushar Deshpande",   Runs: 0, Extras: 0, Wickets: 0},
{BallId: 12, Overs: 1.5, BowlerName: "Tushar Deshpande",   Runs: 0, Extras: 0, Wickets: 0},
{BallId: 13, Overs: 1.6, BowlerName: "Tushar Deshpande",   Runs: 1, Extras: 0, Wickets: 0},
{BallId: 14, Overs: 2.1, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 0},
{BallId: 15, Overs: 2.2, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 1, Wickets: 1},
{BallId: 16, Overs: 2.2, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 17, Overs: 2.3, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 0},
{BallId: 18, Overs: 2.4, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 0},
{BallId: 19, Overs: 2.5, BowlerName: "Deepak Chahar",      Runs: 0, Extras: 0, Wickets: 0},
{BallId: 20, Overs: 2.6, BowlerName: "Deepak Chahar",      Runs: 4, Extras: 0, Wickets: 1},
{BallId: 21, Overs: 3.1, BowlerName: "Maheesh Theekshana", Runs: 0, Extras: 0, Wickets: 0},
{BallId: 22, Overs: 3.2, BowlerName: "Maheesh Theekshana", Runs: 1, Extras: 0, Wickets: 0},
{BallId: 23, Overs: 3.3, BowlerName: "Maheesh Theekshana", Runs: 0, Extras: 0, Wickets: 0},
{BallId: 24, Overs: 3.4, BowlerName: "Maheesh Theekshana", Runs: 0, Extras: 1, Wickets: 0},
{BallId: 25, Overs: 3.5, BowlerName: "Maheesh Theekshana", Runs: 1, Extras: 0, Wickets: 0},
{BallId: 26, Overs: 3.6, BowlerName: "Maheesh Theekshana", Runs: 1, Extras: 0, Wickets: 0},
{BallId: 27, Overs: 4.1, BowlerName: "Mustafizur Rahman",  Runs: 0, Extras: 0, Wickets: 0},
{BallId: 28, Overs: 4.2, BowlerName: "Mustafizur Rahman",  Runs: 4, Extras: 0, Wickets: 0},
{BallId: 29, Overs: 4.3, BowlerName: "Mustafizur Rahman",  Runs: 0, Extras: 0, Wickets: 1},
{BallId: 30, Overs: 4.4, BowlerName: "Ravindra Jadeja",    Runs: 0, Extras: 0, Wickets: 0},
{BallId: 30, Overs: 4.5, BowlerName: "Ravindra Jadeja",    Runs: 0, Extras: 0, Wickets: 0},
{BallId: 30, Overs: 4.6, BowlerName: "Ravindra Jadeja",    Runs: 0, Extras: 0, Wickets: 1}
];

My Expected Output is Like :

var expectedArray = [
{BowlerName: "Deepak Chahar",                      Overs: 1, Run_1: 1, Run_2: 1, Run_3: 0, Run_4: 0, Run_5: 0, Run_6: 4, Run_7: 1, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 7,  Total_Runs: 7,  Wickets: 1},
{BowlerName: "Tushar Deshpande",                   Overs: 2, Run_1: 4, Run_2: 0, Run_3: 4, Run_4: 0, Run_5: 0, Run_6: 1, Run_7: 0, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 9,  Total_Runs: 16, Wickets: 0},
{BowlerName: "Deepak Chahar",                      Overs: 3, Run_1: 4, Run_2: 1, Run_3: 0, Run_4: 4, Run_5: 4, Run_6: 0, Run_7: 4, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 17, Total_Runs: 33, Wickets: 2},
{BowlerName: "Maheesh Theekshana",                 Overs: 4, Run_1: 0, Run_2: 1, Run_3: 0, Run_4: 1, Run_5: 1, Run_6: 1, Run_7: 0, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 4,  Total_Runs: 37, Wickets: 0},
{BowlerName: "Mustafizur Rahman, Ravindra Jadeja", Overs: 5, Run_1: 0, Run_2: 4, Run_3: 0, Run_4: 0, Run_5: 0, Run_6: 0, Run_7: 0, Run_8: 0, Run_9: 0, Run_10: 0, Runs: 4,  Total_Runs: 50, Wickets: 2}
];

My Expected Output to be in a HTML Table like (Image is for Example Only) :

enter image description here

My Expected Output must have :

  1. In the First Over and Third Over, I Have 2 Balls for 1’st over 1’st Ball as an extra, the extra also have to be added in the Runs and Total_Runs of Expected output.

  2. In 3’rd over 2 repeated balls for 2’nd ball, while in the Expected Output have to add it in between the Run_1 to Run_10 column.

  3. The more the extras is there the values between Run_1 to Run_10 columns will increase (as show in the image).

  4. If a Over is shared by 2 players, the Expected Output BowlerName Column have to contain 2 players data (as mentioned in the 5’th Over of Expected Output).

probleme pour lancer l’application [closed]

An unhandled exception occurred: Cannot find module ‘execa’ comment resoudre ce probleme cela apparait lorsque je lance l’application afin de pouvoir s’ouvrir dans le navigateur de mon ordinateur portable

je veux que vous m’aidiez a resoudre ce probleme