How to insert my data from Node JS to BigQuery

This is my code in a class named bqConnection. How would I insert my data from node JS which results the following below to a specific table in bigquery named “sla_table” in the field “expected_start_date” with the parsed data I provided. The name of the location of the table is np-inventory-planning-thd.IPP_SLA.sla_table. According to the “dag_id” I want to appropriately put this parsed data into its correct row. This table is already made I just need to put this new cron parsed data into the expected_start_date field.

log data after parsed:
EFS-Winning-Route-daily-batch
Fri Jul 08 2022 23:00:00 GMT-0500 (Central Daylight Time)
ft-parm-trumping-daily
Fri Jul 08 2022 21:20:00 GMT-0500 (Central Daylight Time)
ft-parm-trumping-weekly
Sun Jul 10 2022 14:00:00 GMT-0500 (Central Daylight Time)
IP_MASTER
Sat Jul 09 2022 04:00:00 GMT-0500 (Central Daylight Time)
IPP_CYCLE_PARMS
Sat Jul 09 2022 13:45:00 GMT-0500 (Central Daylight Time)
ipp-daily-backups
Sat Jul 09 2022 02:00:00 GMT-0500 (Central Daylight Time)
oclt-leadtime-daily
Fri Jul 08 2022 23:00:00 GMT-0500 (Central Daylight Time)
ope-metrics
Sat Jul 09 2022 13:00:00 GMT-0500 (Central Daylight Time)
parm-lite-daily
Fri Jul 08 2022 21:30:00 GMT-0500 (Central Daylight Time)
parm-lite-data-migration
Sat Jul 09 2022 08:00:00 GMT-0500 (Central Daylight Time)
parm-lite-sunday-push-instance
Sun Jul 10 2022 09:00:00 GMT-0500 (Central Daylight Time)

async function accessData(){
    const access = await main();
    const result = access.dag_runs.map(file => ({start_date: file.start_date, end_date: file.end_date, state: file.state, dag_run_id: file.dag_run_id, dag_id: file.dag_id}))
    console.log(result);
    /*await bqConnection()
        .dataset('IPP_SLA')
        .table('sla_table')
        .insert(result);*/
    console.log(`Inserted ${result.length} rows`)
}

(async function () {
    const runs = [
        {
            start_date: '2022-06-26T23:00:00.742495+00:00',
            end_date: '2022-06-27T14:10:23.108401+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-06-25T23:00:00+00:00',
            dag_id: 'EFS-Winning-Route-daily-batch'
        },
        {
            start_date: '2022-07-07T21:20:00.566888+00:00',
            end_date: '2022-07-07T23:20:55.250911+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-07-06T21:20:00+00:00',
            dag_id: 'ft-parm-trumping-daily'

        },
        {
            start_date: '2022-07-03T14:00:00.779718+00:00',
            end_date: '2022-07-03T14:00:41.250433+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-06-26T14:00:00+00:00',
            dag_id: 'ft-parm-trumping-weekly'
        },
        {
            start_date: '2022-07-08T04:00:01.038023+00:00',
            end_date: '2022-07-08T05:08:59.597408+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-07-07T04:00:00+00:00',
            dag_id: 'IP_MASTER'
        },
        {
            start_date: '2022-07-08T13:45:00.757997+00:00',
            end_date: '2022-07-08T14:02:48.050405+00:00',
            state: 'success',
            dag_run_id: 'scheduled__2022-07-07T13:45:00+00:00',
            dag_id: 'IPP_CYCLE_PARMS'
        },
        {
            start_date: '2022-07-08T02:00:00.821824+00:00',
            end_date: '2022-07-08T02:02:06.027268+00:00',
            state: 'success',
            dag_run_id: 'scheduled__2022-07-07T02:00:00+00:00',
            dag_id: 'ipp-daily-backups'
        },
        {
            start_date: '2022-07-07T23:00:01.313332+00:00',
            end_date: '2022-07-07T23:02:37.032427+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-07-06T23:00:00+00:00',
            dag_id: 'oclt-leadtime-daily'
        },
        {
            start_date: '2022-07-08T13:00:00.471935+00:00',
            end_date: '2022-07-08T13:00:49.819534+00:00',
            state: 'success',
            dag_run_id: 'scheduled__2022-07-07T13:00:00+00:00',
            dag_id: 'ope-metrics'
        },
        {
            start_date: '2022-07-07T21:30:00.682954+00:00',
            end_date: '2022-07-07T21:33:29.885878+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-07-06T21:30:00+00:00',
            dag_id: 'parm-lite-daily'
        },
        {
            start_date: '2022-07-08T08:00:01.756909+00:00',
            end_date: '2022-07-08T08:35:55.043131+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-07-07T08:00:00+00:00',
            dag_id: 'parm-lite-data-migration'
        },
        {
            start_date: '2022-07-03T09:00:00.825694+00:00',
            end_date: '2022-07-03T09:10:31.680879+00:00',
            state: 'failed',
            dag_run_id: 'scheduled__2022-06-26T09:00:00+00:00',
            dag_id: 'parm-lite-sunday-push-instance'
        }
    ];

async function determineCron(result){
    /*dagID = result?.[0]?.dag_id || 0*/
    dagID = result ? result.dag_id : 0
    console.log(dagID)
    job = await bqConnection().query(`SELECT * FROM `np-inventory-planning-thd.IPP_SLA.expected_sla` where dag_id = "${dagID}"`)
    cronTime = job[0][0].cron_time
    var interval = parser.parseExpression(cronTime);
    console.log(interval.next().toString());
}
    for (let run of runs) {
        var re = new RegExp('(Central Daylight Time)');
        await determineCron(run);
    }
})();

Why are the values unavailable outside of a function even though it’s been initialized before?

I can’t get the deleteTaskId variable available after the inner function is run. What am I missing?

function deleteTask() {
  const delTask = document.querySelectorAll(".del-btn");
  let deleteTaskId = 0;
  for (let i = 0; i < delTask.length; i++) {
    delTask[i].addEventListener("click", function(event) {
      let dataTr = event.target.parentNode;
      deleteTaskId = dataTr.parentNode.querySelectorAll("td")[1].innerText;
      console.log(deleteTaskId); //Log = 5
    });
  }
  console.log(deleteTaskId) //Log = 0
  const td = event.target.parentNode;
  const tr = td.parentNode;
  tr.parentNode.removeChild(tr);
}

Thank you!

Name a variable to a variable in discord.js?

the title says all, I would like to name a variable to a variable. Here is a small example of what I want:

    let messages = [
    {
        name: "message1",
        message: "hi, this is a message"
    },
    {
        name: "message2",
        message: "hi, this is a message too"
    }
]
messages.forEach(message => {
    let message_name_content_here = message //here
})
console.log(message_name_content_here.name)//here

How can I do that?

Cant get value of the search bar and assign it into API

I cant assign the value to API, I tried giving it a default value then change it but it still not working (I’m new with API’s), the variable is city.

searchBtn.addEventListener("click", function(){
        let searchValue = document.getElementById("searchbar").value;
          let city = searchValue;
    })
    
     fetch(`http://api.weatherapi.com/v1/forecast.json?key=${apik}&q=${city}&days=7`)

Difference between writing JS/HTML code in .HTML file and shiny

When I write the below code in .html and execute, it works fine

<h1> Chnge the html content </h1>
<h2 id = 'hcontent'> Hello Manu </h2> 
<h3> Welcome </h3>
<button type = 'button' onclick='document.getElementById('hcontent').innerHTML='Hello Mr Manu'>Click here </button>

But when I write the same in shiny , it does not.
Can anyone help me on how to execute it?

library(shiny)
library(shinyjs)
# source("myfun.R")

ui <- fluidPage(
  useShinyjs(),
tags$head(HTML("<h1> Chnge the html content </h1>
<h2 id = 'hcontent'> Hello Vinay </h2> 
<h3> Welcome </h3>
<button type = 'button' onclick='document.getElementById('hcontent').innerHTML='Hello Mr Vinay'>Click here </button>"))
)

server <- function(input, output, session) {

  
}

shinyApp(ui, server)

Why is one of my functions isn´t working while onclick event?

I have a form with fields for password and confirm password and other input fields. I created a function that calls other functions. Basically this one function calls a function that shows a confirmation message before submitting my form, and the other function is a validation for the two password fields to be equal.

So the function that is showing the confirmation message does work but the validation for passwords doesnt.

function confirmarAlta(){
            
            var result = confirm("Esta seguro que desea crear este usuario?");
            
            if(result == false){
                event.preventDefault();
            }
        }
    
    
 function verificarPassword(){
        var pass = document.querySelector(".password").value;
        var confirmPass = confirmPassword.querySelector(".confirmPassword").value;
        console.log(pass);
        console.log(confirmPass)
            
        if(pass != confirmPass){
            alert("Las contraseñas no coinciden");
            pass = "";
            confirmPass = "";
        }
        
    }   
    
    
function Validaciones(){
            verificarPassword();
            confirmarAlta();
        }
<div class="form-group">
              <label>Contraseña: </label>
              <input type="password" class="form-control password" name="txtPassword" required>
            </div>
            <div class="form-group">
              <label>Repetir Contraseña: </label>
              <input type="password" class="form-control confirmPassword"  name="txtConfirmarPassword" required>
            </div>
          
          
          
          <input onclick="Validaciones()" type="submit" class="btn btn-success" value="Aceptar" name="btnAceptar">

The error im getting is confirmPassword is not defined.

WordPress Block issue

    const icon = el(
        Icon,
        {
            icon: el(
                SVG,
                {
                    width: 20,
                    height: 20,
                    viewBox: '0 0 576 512',
                },
                el(
                    Path,
                    {
                        d: 'long svg',
                    },
                ),
            ),
        },
    );
    
    const svg = el(
        SVG,
        {
            viewBox: '0 0 467.96 692.45',
            width: 24,
            height: 24,
        },
        el(
            Path,
            {
                d: 'another long svg',
            },
        ),
    );
    
    registerBlockType(
        metadata,
        'archer-tire-tracks',
        {
            icon,
            svg,
    
            edit: () => {
                return [
                    el(
                        'svg',
                        {
                            className: 'archer-tire-tracks',
                        },
                    ),
                ];
            },
    
            save: () => {
                return el(
                    'svg',
                    {
                        className: 'archer-tire-tracks',
                    },
                );
            },
        },
    );

I can’t seem to get the icon to actually appear when trying to implement it within a block, also getting a “The editor has encountered an unexpected error.” whenever trying to implement it. I’ve tried a nice bit but I just can’t seem to figure it out. I’ll take any help at all, thank you all. I have all the necessary imports and everything so that isn’t an issue.

How to update a location on a map in real time

I am currently attempting to make a small web app that can track the location of satellites (Specifically ISS) using the ‘Where the ISS at’ API. I want the website to have a map, with a marker, that displays the precise position of the satellite every second.
I currently have the application set up to use the Google maps API. However, I am concerned about the pricing of this. Apparently the maps API is free for 90 days and then works on a $300/month free credit service (equivalent of 100,000 requests a month). The main thing that worries me is the application will make a request to the maps API every second which would then be 2,678,400 requests a month which could get very pricey. Yet, I could be completely miss interpreting the pricing structure.

Code:

const WHERE_THE_ISS_AT_API = 'https://api.wheretheiss.at/v1/satellites/25544'; // Where the ISS at API key

// Get current lat, long, alt and velocity data from ISS API:
async function getSatData() {
    const data = await getData(WHERE_THE_ISS_AT_API); // Call API URL to fetch data
    // Store data in array:
    const satData = {
        lat: data.latitude,
        lng: data.longitude,
        alt: data.altitude,
        vel: data.velocity
    };
    return satData;
}

// Call API and get result:
async function getData(URL) {
    const response = await fetch(URL);
    const data = await response.json();
    return data;
}

// Updates the elements on screen displaying ISS stats
function displayISSData(latitude, longitude, altitude, velocity) {
    document.getElementById('latitude').textContent = latitude;
    document.getElementById('longitude').textContent = longitude;
    document.getElementById('altitude').textContent = altitude;
    document.getElementById('velocity').textContent = velocity;
}

function newMarkerPos(coordinates, marker) {
    const newPos = new google.maps.LatLng(coordinates.lat, coords.lng);
    marker.setPosition(newPos);
}

// Update coordinates/map position based on API stats every 2 secs:
function update() {
    const initialCoords = { lat: 51, lng: 1 }; // Position on page load

    displayISSData('Getting lat', 'Getting long', 'Getting alt', 'Getting vel') // Notify user of loading status

    const map = new google.maps.Map(
        document.getElementById('map'),
        {
            zoom: 5,
            center: initialCoords,
            streetViewControl: false,
            mapTypeId: 'hybrid'
        }
    );

    const marker = new google.maps.Marker({
        title: 'ISS',
        position: initialCoords,
        map: map,
        clickable: true,
        icon: {
            url: 'images/sat.png',
            scaledSize: new google.maps.Size(40, 40)
        }
    });

    // Do this every 1 secs:
    setInterval(() => {
        const fullData = getSatData(); // Get data from API
        fullData.then(satData => {
            const coordinates = { lat: satData.lat, lng: satData.lng };
            // map.setCenter(coordinates);
            displayISSData(satData.lat, satData.lng, satData.alt, satData.vel);
            // updateMarkerPosition(coordinates, maker)
        });
    }, 1000);
}

window.onload = () => update();

I would appreciate it if somebody could give me some clarity on the Google Maps API pricing structure or suggest a cheaper/free maps API alternative that could do exactly the same thing as the code above. I don’t really want to pay for the API as this is just a fun little project that will see no commercial use. Thanks in advance.

how to call sql queries from js files in index.html

i managed to install sqlite in electron but now i have the problem of how to call sql queries in my html file.
I tried using the following code in
index.html

<script type='text/javascript' src='query_table.js'></script>

in query_table.js:

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('db.sqlite');

function hello() {
 
    console.log("sssssssssssssssssssssssssssssssssssssssssssss");
    db.serialize(() => {
 

        db.each("SELECT *  FROM events", (err, row) => {
            console.log(row.id + ": " + row.data);
        });
       });
       
       db.close();
}

but I get this error when I launch my app:

Uncaught ReferenceError: require is not defined

what is the right way to call functions using the db? i would like to create several js files based on the various models i have (tables in my db). I would like to import a model to run sql queries based on where I am within my app. How should this be done? What is the best practice?

Trying to incorporate JS into shiny

I am trying to incorporate JS into Shiny that is without writing anything to server. Here is the code

library(shiny)

ui <- fluidPage(
  tags$head(HTML('<p id="res">Value</p>'),
  tags$script("document.getElementById('res').innerHTMl=x")),
  textInput("x", label = "Text")
)

server <- function(input, output) {
}

shinyApp(ui, server)

So basically, whatever we write inside the text box, the “Value” should get changed.
Can anyone help me?

mat-checkbox in mat-tree not rendering properly

Im working on a new Word add-in using th JS API. Im trying to put together a tree with checkboxes in one of the panes, but the checkboxes are looking weird:
enter image description here

as you can see there are two sets of boxes, and when I check one of them theres a double check mark. Im not sure why this is as I followed the instructions here: https://material.angular.io/components/tree/examples

This is what my html looks like:

<mat-tree [dataSource]="dataTree" [treeControl]="treeControl" multiTemplateDataRows> 
    <mat-tree-node *matTreeNodeDef="let node; when: hasChild" matTreeNodePadding>
        <button
          mat-icon-button
          matTreeNodeToggle
          [attr.aria-label]="'Toggle ' + node.item"
        >
          <mat-icon class="mat-icon-rtl-mirror">
            {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
          </mat-icon>
        </button>
        <mat-checkbox
          [checked]="test(node)"
          [indeterminate]="test(node)"
          (change)="test(node)"
          >{{node.name}}</mat-checkbox
        >
      </mat-tree-node>
</mat-tree>

I have this reference to the material stylesheet in my index.html:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

And lastly I have the following imports:

import { MatTreeModule } from "@angular/material/tree";
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';

Any idea why its rendering so weird? Also you will notice a grey area around the “chevron” icon. In the sample I found online it seems that the circle only appears when you click on the chevron icon to expand, but in practice it seems to always be there.

Is this a limitation of the Word API?

Make any part of a child DIV opaque if it is outside of the area of the parent DIV without overflow:hidden

I have a div inside of another div and the inner div can be sized up by the user.

Currently if they size it up then it covers over the outer div completely unless I use overflow:hidden but then they can’t see the outer edges of the inner div anymore.

Ideally I would like, if the innerdiv reaches outside the boundary of the parent outerdiv, I would like anything outside of said boundary to look different, ideally just an opacity setting.

Basically I am looking for something like

overflow:opacity .3;

Currently I just have a hidden or not-hidden setting that is toggled, but it isn’t ideal.

This is what it would look like with the innerdiv set to the color red. Any part of that innerdiv that is outside of the outerdiv is opaque. (The pink & red element is the same div. The full red part is the boundary of the parent/outer div.)

enter image description here

I have an un-working example below.

I am open to other ways of setting this up, but if it can be done with the configuration below it would be ideal.

I am fine doing this with javascript/jQuery as well.

.frame {
  width:200px;
  height:200px;
  margin-left:auto;
  margin-right:auto;
  display;block;

  margin-top:30px;
  
}


.outerdiv {
width:200px;
height:200px;
 background:gray;
 border:solid 1px #C0C0C0;
}



.innerdiv {
  width:240px;
  height:240px;
  position:absolute;
  background:red;
  margin-left:-20px;
  margin-top:-20px;
  opacity:.2
  
}
<div class="frame">
<div class="outerdiv">
<div class="innerdiv">

</div>
</div>
</div>

¿how can i copy a Spreadsheet without the appscript in it?

good day i have a little problem here… you see i’ve been working in a project in appscript that this (the appscript file) is allocated in a google sheets file. and i want to copy this same google – sheets with the data in it and “send” the copy to another folder, i made this script for the task (for copying i mean):

    var CopyOfSheet = SpreadsheetApp.openById(Thischit).copy(Name.of.the.sheet).getId();
    var SpecificFolder = DriveApp.getFolderById(ExlID);
    var File = DriveApp.getFileById(CopyOfSheet);
    SpecificFolder.addFile(File);
    File.getParents().next().removeFile(File);

when the function is triggered (by any means even just executing the script does it) it generates a copy in the selected folder.

but here is the catch… it also copies the appscript code and i don’t want the appscript in the copy so here is the thing…

¿how can i copy the sheet without the script? (remember that the script is in the google sheet that is being copied.
… thanks in advance.

Why does the content on my page disappear when I surround the component with a Route tag?

Guys I’m loading some json data about movies on to my page, I would like to click on the title of the movie to get additional information about that specific movie. However when I place a Router tag around the component, nothing is displayed on the page. What could be the issue?

Here’s the json data:

{
"movies":[
    {
        "title": "Spiderhead",
        "cover": "images/Spiderhead.jpeg",
        "description": "In the near future, convicts are offered the chance to volunteer as medical subjects to shorten their sentence. One such subject for a new drug capable of generating feelings of love begins questioning the reality of his emotions.",
        "year": 2022,
        "genre": "Action",
        "length": "1h 46m",
        "viewer_rating":  5.4,
        "critic_rating": 2.0,
        "critiques": [
            {
                "critic_name": "Roger Ebert",
                "image": "spiderhead_critic",
                "feedback": "Though it starts with promise, 'Spiderhead' is pseudo-heady sci-fi stuff that treats its most intriguing elements like an afterthought, and misses the opportunity to be a memorable oddity aside from its disappointments.",
                "rating": "**"
            }
        ]
    },
    {
        "title": "THE MAN FROM TORONTO",
        "cover": "images/man_from_toronto.jpg",
        "description": "The Man From Toronto has a crackerjack premise and a fine pair of stars, but this toothless comedy mismatches its promising elements and winds up neither funny or thrilling.",
        "year":2022,
        "genre": "Action, Comedy",
        "length": "1h 50m",
        "viewer_rating": "42%",
        "critic_rating": "24%",
        "critiques": [
            {
                "critic_name": "Calum Marsh, New York Times",
                "critic_image": "https://www.asso-sherpa.org/wp-content/uploads/2018/03/new-york-times-logo.jpg",
                "feedback": "Although Hart, as the broadly comic version of the classic Hitchcockian Wrong Man, has a certain goofball charm, his frantic coward routine gets old quickly, with no appreciable change as the action-flick danger continues to escalate.",
                "rating": 3.6
            }
        ]
    },
    {
        "title": "Public Enemies",
        "cover": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRdKrxTlMnQa6f4JJkzTQAO3nIkep-8rqUnRtFUxbbvsIaXitgY",
        "description": "John Dillinger, Baby Face Nelson and Pretty Boy Floyd are gangsters who have terrorised the city. Federal agents try their best to nab them.",
        "year": 2009,
        "genre": "Action, Biography, Crime",
        "length": "2h 20m",
        "viewer_rating": "68%",
        "critic_rating": 4.0,
        "critiques": [
            {
                "critic_name": "Written by Richard Propes The Independent Critic",
                "critic_image: ": "https://www.adamfazel.com/img/TheIndependentCriticlogo.png",
                "feedback": "While 'Public Enemies' never quite soars to the heights of 'Bonnie & Clyde' or 'The Untouchables,' it is easily one of 2009's most satisfying action dramas for adults. Featuring memorable performances from Depp and Cotillard and a strong supporting cast, 'Public Enemies' is an intelligent and compelling story about a man whose true story is as intriguing as the myth that has enveloped his life long after his death.",
                "rating": " "
            }
        ]
    },{
        "title": "Trauma",
        "cover": "https://m.media-amazon.com/images/M/MV5BZmIzN2ZkNDEtNjJmNS00ZDNmLWE3YTctN2UwZTdjYzIyZDkzXkEyXkFqcGdeQXVyMTI0NTEyNzU@._V1_.jpg",
        "description": "Four friends, partying in a house in the middle of nowhere are brutally attacked by a man and his son, forcing the remaining women to take vengeance upon them.",
        "year": 2017,
        "genre": "Action, Drama, Horror",
        "length": "1h 46m",
        "viewer_rating": " ",
        "critic_rating": " ",
        "critiques":[
            {
                "critic_name": "411MANIA",
                "critic_image": "https://cdn-cache.wrestlingnewssource.com/u/webp_full/c616679e401bcae1eafcaefb1a72fe11_767_409.webp",
                "feedback": "Trauma is not a “fun” horror movie. Again, it's hard to sit through and will make you question man's inhumanity to man. It will also make you hate life. If you're not a fan of extreme horror don't even bother with Trauma. You won't get through it."
            }
        ]
    },{
        "title": "Hustle",
        "cover": "https://m.media-amazon.com/images/M/MV5BYjdhYTE3NjMtZjI3OC00NzVlLWFiNTUtNzQ3NDNiNTI3NDg4XkEyXkFqcGdeQXVyMTEyMjM2NDc2._V1_FMjpg_UX1000_.jpg",
        "description":"A basketball scout discovers a phenomenal street ball player while in Spain and sees the prospect as his opportunity to get back into the NBA.",
        "year":2022,
        "genre": "Drama, Comedy, Sport",
        "length": "1h 57m",
        "viewer_rating": "7.4",
        "critic_rating": "7",
        "critiques": [
            {
                "critic_name": "3 brothers film",
                "critic_image": "3 brothers film",
                "feedback": "What’s the difference between the players who make it and those who don’t? The preparation. The obsession. The hustle. This film charts the hard work in between the big moments. It’s a movie about an NBA lifer made for lifelong fans."
            }
        ]
    },
    {
        "title": "Top Gun: Maverick",
        "cover": "https://mlpnk72yciwc.i.optimole.com/cqhiHLc.WqA8~2eefa/w:auto/h:auto/q:75/https://bleedingcool.com/wp-content/uploads/2022/05/FSaEkRhVEAEVUQO.jpeg",
        "description": "After more than thirty years of service as one of the Navy's top aviators, Pete Mitchell is where he belongs, pushing the envelope as a courageous test pilot and dodging the advancement in rank that would ground him.",
        "year": 2022,
        "genre": "Action, Drama",
        "length": "2h 10m",
        "viewer_rating": 8.6,
        "critic_rating": "96%",
        "critiques": [
            {
                "critic_name": "Tony Macklin",
                "critic_image": "http://tonymacklin.net/images/macklin.jpg",
                "feedback": "The expectations for the sequel have been percolating for two years. It was supposed to be released in 2020, but COVID prevented that. he original had only one Black pilot. Top Gun: Maverick has more minority actors, and one of its major pilots is a female, 'Phoenix,' played by Monica Bavaro. Bavaro reportedly is the only one of the major actors along with Cruise who didn't throw up during the intense training for the flights."
            }
        ]
    },
    {
        "title": "Black Mass",
        "cover": "https://m.media-amazon.com/images/M/MV5BNzg0ODI3NDQxNF5BMl5BanBnXkFtZTgwMzgzNDA0NjE@._V1_.jpg",
        "description": "The true story of Whitey Bulger, the brother of a state senator and the most infamous violent criminal in the history of South Boston, who became an FBI informant to take down a Mafia family invading his turf.",
        "year": 2015,
        "gener": "Biography, Crime, Drama",
        "length": "2h 3m",
        "viewer_rating": 6.9,
        "critic_rating": ""
    }
]
}

Here’s the App.js code:

import React from 'react';
import './App.css';
import MovieCard from './MovieCard'
import Movies from './Movies';
import Homepage from './Homepage';
import test from './test';
import data from './data.json'
import { BrowserRouter as Router, Route } from 'react-router-dom';
function App() {
return (
<Router>
   <div className='App'>
    <Router>
      <Movies />
    </Router>
   </div>
</Router>
);
}

export default App;

Code that renders the card to the page, Movie.js:

import React from "react";
import { useState } from "react";
import data from './data.json'
import { Link, BrowserRouter } from "react-router-dom";
import './App.css'
const Movies = () =>{
const [search, setSearch] = useState("");
var display = document.getElementsByClassName("app");
return(
    <div className="nav-bar">
        <nav>
            <input type="text" className="searchbar" placeholder="Search.." onChange={e => {setSearch(e.target.value)}}/><br></br><br></br>
        </nav>
        {data.movies.filter((val)=>{
            if(search==""){
                return val;
            }else if(val.title.toLocaleLowerCase().includes(search.toLocaleLowerCase())){
                return val;
            }
        }).map((val,key)=>{
            return (
                <div className="movie-card" key={key}>
                    <p className="title">{val.title}</p> <br></br>
                    <img src={val.cover}/> <br></br>
                    {/* <Link to={`fulldetails/${val.title}`}></Link> */}
                </div>
            )
        })}
    </div>
)
}
export default Movies;