Unexpected token, expected “;” Error while passing object from FetchMovie to MovieList component

This is MovieList.js and I passed a react object as prop to this component from FetchMovie.js which I gave below. I tried but it’s still there . Pls help

MovieList.js

import React from "react";
function MovieList(props) {
  console.log(props.newFilm)
  let imgURL= props.newFilm.images.still.2.medium.film_image
  return (
    <div className="filmm">
      <h1>{props.newFilm.film_name}</h1>
      <img src={imgURL} />   
    </div>
  );
}

export default MovieList

FetchMovie.js
This is the FetchMovie.js file and through this component I passed users object as a prop to MovieList.js and that error occured. Pls help.
I have given the users object below the FetchMOvies.js.

import React, { useState } from "react";
import MovieList from "./MovieList";
import users from "./MovieView";
let s = users.films;
function FetchMovies() {
  return (
    <div>
      {s.map((film) => (
        <MovieList key={film.film_id} newFilm={film} />
      ))}
    </div>
  );
}

export default FetchMovies;

This is the users object:

users={
  films: [
    {
      film_id: 258136,
      imdb_id: 2119543,
      imdb_title_id: "tt2119543",
      film_name: "The House With A Clock In Its Walls",
      other_titles: {
        EN: "The House With A Clock In Its Walls"
      },
      release_dates: [
        {
          release_date: "2018-09-21",
          notes: "GBR"
        }
      ],
      age_rating: [
        {
          rating: "12A ",
          age_rating_image:
            "https://d2z9fe5yu2p0av.cloudfront.net/age_rating_logos/uk/12a.png",
          age_advisory: "moderate threat, scary scenes"
        }
      ],
      film_trailer: "https://dzm1iom8kpoas.cloudfront.net/258136_uk_high.mp4",
      synopsis_long:
        "In the tradition of Amblin classics where fantastical events occur in the most unexpected places, Jack Black and two-time Academy Award® winner Cate Blanchett star in THE HOUSE WITH A CLOCK IN ITS WALLS, from Amblin Entertainment.  The magical adventure tells the spine-tingling tale of 10-year-old Lewis (Owen Vaccaro) who goes to live with his uncle in a creaky old house with a mysterious tick-tocking heart.  But his new town's sleepy façade jolts to life with a secret world of warlocks and witches when Lewis accidentally awakens the dead.",
      images: {
        poster: {
          "1": {
            image_orientation: "portrait",
            region: "US",
            medium: {
              film_image:
                "https://d3ltpb4h29tx4j.cloudfront.net/258136/258136h1.jpg",
              width: 200,
              height: 300
            }
          }
        },
        still: {
          "2": {
            image_orientation: "landscape",
            medium: {
              film_image:
                "https://d3ltpb4h29tx4j.cloudfront.net/258136/258136h2.jpg",
              width: 300,
              height: 199
            }
          }
        }
      }
    }
  ],
  status: {
    count: 1,
    state: "OK",
    method: "filmsComingSoon",
    message: null,
    request_method: "GET",
    version: "ZUPIv200",
    territory: "UK",
    device_datetime_sent: "2018-09-14T09:26:34.793Z",
    device_datetime_used: "2018-09-14 09:26:34"
  }
};

Getting similar songs using Last.fm API

I’m trying to use Last.fm’s API to find similar songs given a song name. Last.fm has a feature that can do this called track.getSimilar, but both “track” and “artist” are required parameters. However, because of the way this works, I can’t figure out a way to either a) get both a song name, and the artist from one search bar input, or b) get the song’s artist using track.search. Here’s the part of my code relating to this:

useEffect(() => {
  fetch(`${API_GET_SIMILAR_URL}&page=${RESULT_PAGE}&artist=${DEFAULT_ARTIST}&track=${DEFAULT_TRACK}`)
    .then(response => response.json())
    .then(jsonResponse => {
      const tracks = jsonResponse.similartracks[Object.keys(jsonResponse.similartracks)[0]];
      dispatch({
        type: "SEARCH_SUCCESS",
        payload: tracks
      });
    });
}, []);

const search = (searchValue) => {
  dispatch({
    type: "SEARCH_REQUEST"
  });
  fetch(`${API_GET_SIMILAR_URL}&page=${RESULT_PAGE}&track=${searchValue}`)
    .then(response => response.json())
    .then(jsonResponse => {
      if (!jsonResponse.error) {
        const tracks = jsonResponse.similartracks[Object.keys(jsonResponse.similartracks)[0]];
        dispatch({
          type: "SEARCH_SUCCESS",
          payload: tracks
        });
      } else {
        dispatch({
          type: "SEARCH_FAILURE",
          error: jsonResponse.error
        });
      }
    });
};

let {
  tracks,
  errorMessage,
  loading
} = state;
console.log(state);

In my search function I’m getting an Uncaught (in promise) TypeError: Cannot convert undefined or null to object error in the Object.keys line because I’m not using the artist parameter when calling the API. I tried using track.search to get the artist but I’m not sure where/how to incorporate it into my code.

I appreciate any help or advice. Thanks.

Telegraf.js referencing Telegram client API and initializing a new Telegram client

Hi so I’m trying to initialize a Telegram client API just like Telegraf API shows and I run into a problem when running it, and I can’t really figure out why it is happening.

const { Telegraf } = require('telegraf')

//Here is where the problem happens
const Telegram = require('telegraf/telegram')

const tBot = new Telegraf('5195445301:AAGg4j0cqq8Ox7yvRr3X_H2zM9ZsQLOnet0')

The thing is that I can create the bot and run functions for the replies for the messages but I want to make a function that calls the function:

telegram.getFileLink(fileId)

This function executes over a function of the type Telegram initialized by this:

const telegram = new Telegram(token, [options])

And it cannot be executed by the Telegraf object which represents the bot. The error I am getting is the following(which happens when using the require on ‘telegraf/telegram’):

**
internal/modules/cjs/loader.js:455
throw e;
^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./telegram’ is not defined by “exports” in E:JSlaigDocumentsCodingTel2DTel2Dnode_modulestelegrafpackage.json
**

How to use variable which used inside function out of function js reactjs

I get array names flashcards when I mount the app.

flashcards=[
{id:1, check1:false, check2:false, check3:false},
{id:2, check1:true, check2:true, check3:true},
{id:3, check1:true, check2:false, check3:false}
]

I filtered this array if check1,check2,check3 are true.
I filtered this array inside function. But I want to use filtered object outside function.

  let fl;
  console.log('fl outside',fl)  // undefined

  const checkIfAuth = () => {
  if (flashcards.statusCode === 401 || flashcards.statusCode === 403) {
    console.log('This is not authorized')
    setAuth(true)
  } else {
    // console.log('Authorizaed')
    setAuth(false)
    const checkIfFlase = (flashcard) => {
      return flashcard.check1 === false || flashcard.check2 === false || flashcard.check3 === false
     }
    
     fl = flashcards.filter(checkIfFlase)
     console.log('fl inside', fl)   
   // ↑ filtered right objects 
   // [{id:1, check1:false, check2:false, check3:false},{id:3, check1:true, check2:false, check3:false}]
    
  } 
}

How can I update fl outside function?

Any advice is appreciated.

How to get data from a tag with javascript [duplicate]

is there any way to obtain data or the value that is inside a label?
I need to get the value that is inside the tag <label id="domTextElement"></label>

  <label id="domTextElement">Name: </label>
 
  

  <p id="valueInput"></p> 

  <script> 

    var inputValue = document.getElementById("domTextElement").data; 
      document.getElementById("valueInput").innerHTML = inputValue; 
   
    
  </script> 

Somehow?
Thanks

Why is lazy loading not stopping HTML Images from loading?

I am working with a clients website, he wanted his 139 pictures added to his project page and the site takes forever to load, doesn’t load all images, I added lazy load into the IMG tags and it still takes forever. I NEED THESE IMAGES TO LOAD UPON SCROLLING THROUGH THE GALLERY GRID.

<div class="project-item">
<img src="Projects/1.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">

<img src="Projects/2.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/3.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/4.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/5.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/6.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/7.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/8.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/9.jpeg" height="250" width="175" alt="projects" loading="lazy" />

</div>
<div class="project-item">
<img src="Projects/10.jpeg" height="250" width="175" alt="projects" loading="lazy" />

Discord.js bot error with repeated message that seemingly comes from nowhere

I am getting a problem where when i try to 1v1 someone, it continues to say “Looks like the user you are trying to 1v1 is passive!”

This is using the latest version of quick db and discord js.

I am guessing this is just a silly mistake i made when typing something in. If so, let me know!

Here is my 1v1request code:

const db = require("quick.db");
const Discord = require('discord.js');
const client = new Discord.Client();
const fs = require('fs');
const { MessageEmbed } = require('discord.js')
const talkedRecently = new Set();

module.exports = {
  name: '1v1request',
  description: 'request someone to have a 1v1 ',
  execute(message, args, client) {

    if (talkedRecently.has(message.author.id)) {
      message.reply("Wait 1 day before being able to use this command again.");
    } else {

      const userto1v1 = message.mentions.users.first()

      if (!userto1v1) {
        message.channel.send('Make sure to specify a user!')
      } else {

        let userto1v1passive = db.get(`passive_${message.guild.id}_${userto1v1.id}`)

        if (userto1v1passive = 1) {

          message.channel.send("Looks like the user you are trying to 1v1 is passive!")

        } else {

          let amipassive = db.get(`passive_${message.guld.id}_${message.author.id}`)

          if (amipassive = 1) {

            message.channel.send("You are on passive!")

          } else {

            let trophies = db.get(`trophies_${message.guild.id}_${message.author.id}`)

            let trophies1 = db.get(`trophies_${message.guild.id}_${userto1v1.id}`)

            if (trophies < trophies1) {

              let trophiestobelost = (trophies1 - trophies) + 10

              client.channels.cache.get('944400414642688000').send(`**New 1v1 Request** - ${message.author} wishes to 1v1 ${userto1v1}! ${userto1v1} has 2 days to respond before they lose ${trophiestobelost} trophies!`);
              talkedRecently.add(message.author.id);
              setTimeout(() => {
                talkedRecently.delete(message.author.id);
              }, 86400000);

            } else {
              message.channel.send("You can't 1v1 someone with less or equal trophies than you!")
            }

          }
        }
      }
    }
  }
}

and here is my passive command code.

const db = require("quick.db");
const Discord = require('discord.js');
const client = new Discord.Client();
const fs = require('fs');
const { MessageEmbed } = require('discord.js')
const talkedRecently = new Set();

module.exports = {
  name: 'passive',
  description: 'turn on passive',
  execute(message, args, client) {

    if (talkedRecently.has(message.author.id)) {
      message.reply("Wait 2 days before being able to use this command again.");
    } else {

      let filter = m => m.author.id === message.author.id
      message.channel.send(`Would you like to enable or disable passive? `ENABLE` / `DISABLE``).then(() => {
        message.channel.awaitMessages(filter, {
          max: 1,
          time: 30000,
          errors: ['time']
        })
          .then(message => {
            message = message.first()
            if (message.content.toUpperCase() == 'ENABLE' || message.content.toUpperCase() == 'E') {

              db.set(`passive_${message.guild.id}_${message.author.id}`, 1)
              message.channel.send('Passive Enabled. Disabling passive will let you re-enable passive in 2 days. Passive will be automatically removed after 2 days.')

              setTimeout(() => {
                db.set(`passive_${message.guild.id}_${message.author.id}`, 0)
              }, 172800000);

            } else if (message.content.toUpperCase() == 'DISABLE' || message.content.toUpperCase() == 'D') {

              db.set(`passive_${message.guild.id}_${message.author.id}`, 0)

              message.channel.send('Succesfully disabled. You can use this command again in 2 days.')

              talkedRecently.add(message.author.id);
              setTimeout(() => {
                talkedRecently.delete(message.author.id);
              }, 172800000);

            } else {
              message.channel.send(`Invalid Response.`)
            }
          })
          .catch(collected => {
            message.channel.send('Timeout. Did not answer in time.');
          });
      })
    }

  }
}

React Navigation – Listen parent action in child component

I have a tab navigator Screen in which there are 2 tabs. The parent Stack has button in the header, which should work differntly w.r.t Two different screens/Tabs.

enter image description here

Now, What I have done is –

navigation.setOptions({
  headerRight: () => (
    <TouchableOpacity>
      <Text>Update</Text>
    </TouchableOpacity>
  ),
});

How I can handle the click of Save button from both the components under Tabs Navigator?

Note – I am using react-navigation@v6

Typescript: How to push elements to Global Variable array and access outside of function [duplicate]

I’m a typescript/javascript beginner, and I’m having trouble understanding how Global Variables work. I’m trying to push elements into a Global Variable inside a function, and then access those contents outside of the function. However, when I try logging the array outside of the function, it returns an empty array. How can I access those contents outside of the function?

I want to do something like this:

        let myArray: string[] = [];

        getReports().then(reports => {
            reports.forEach((report) => {
                myArray.push(report.coolTitle);
            });
            //If I log myArray here, I can see a list of report titles
            cy.log(JSON.stringify(myArray));
        });

//I want to access the new contents of myArray out here, but it returns an empty list
cy.log(JSON.stringify(myArray));

drawing image on HTML Canvas gives error: “Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable”

I am trying to do pixel sorting and drawing an image afterwards. The problem is that sometimes the image loads after sorting and sometimes it gives the above mentioned error. From console, the error is apparently coming from ‘let newImageData’ which you will find in second function. The variables newColorArr and img are global. Here’s my code:

function processImg(image, callback) {
    image.onload = ()=> {
        c.drawImage(image, 0, 0, image.width, image.height);
        let imageData = c.getImageData( 0, 0, image.width, image.height);
        callback(imageData); 
    } 
}



function applyFilter(imageData) {
    colorArr2D = make2DArr(imageData);
    sorted2DArr = selectionSort(colorArr2D);
    fillNewArr(sorted2DArr);
    let newImageData = new ImageData(newColorArr, img.width, img.height);
    c2.putImageData(newImageData, 0,0);
}

How do I solve this issue?

Can I append inline elements and align them to the left?

I am appending h4 elements to a div with the class of teamDisplay. I want the appended elements to be centered on the page but aligned to the left. For example, I want the alignment to look like this (aligned left)

            4. New York Giants
            5. Green Bay Packers
            6. Buffalo Bills

however, the appended elements are currently aligning to the center like so

           4. New York Giants
          5. Green Bay Packers
            6. Buffalo Bills

I have tested removing my appendInline class which then aligned everything to the left, however, all the appended elements appeared on separate lines rather than on one single line. In this question, the responders say that display: inline and text-align wouldn’t have any affect together. I thought that I would be able to get past that by wrapping my appended inline elements in a div with display: inline-block and text-align: left, but to no avail.

html

<body>
  <div id="newFavTeamDiv" class="teamDisplay"></div>
</body>

css

body {
  text-align: center;
}
.teamDisplay {
  display: inline-block;
  text-align: left;
}
.appendInline {
  display: inline;
}

javascript

  // create elements
  var teamNumber = document.createElement("h4");
  var teamCityName = document.createElement("h4");
  var teamMascotName = document.createElement("h4");
  ...
  // assign elements "display: inline" property so they they all appear on the same line when they are appended together. This is where I run into the issue: I want the h4 elements to append on one line (that is why I use inline) and align to the left within the center inline-block div that they are being appended to, but instead they are currently aligning center
  teamNumber.className = "appendInline"; 
  teamCityName.className = "appendInline";
  teamMascotName.className = "appendInline"; 
document.getElementById("newFavTeamDiv").append(teamNumber, teamCityName, " ", teamMascotName);

v8 – how to debug Map.prototype.set and OrderedHashTable?

I’m learning more about v8 internals as a hobby project. For this example, I’m trying to debug and understand how Javascript Map.prototype.set actually works under-the-hood.

I’m using v8 tag 9.9.99.

I first create a new Map object in:

V8 version 9.9.99
d8> x = new Map()
[object Map]
d8> x.set(10,-10)
[object Map]
d8> %DebugPrint(x)
DebugPrint: 0x346c0804ad25: [JSMap]
 - map: 0x346c08202771 <Map(HOLEY_ELEMENTS)> [FastProperties]
 - prototype: 0x346c081c592d <Object map = 0x346c08202799>
 - elements: 0x346c08002249 <FixedArray[0]> [HOLEY_ELEMENTS]
 - table: 0x346c0804ad35 <OrderedHashMap[17]>
 - properties: 0x346c08002249 <FixedArray[0]>
 - All own properties (excluding elements): {}

When I break out of d8 into gdb, I look into the table attribute

gef➤  job 0x346c0804ad35
0x346c0804ad35: [OrderedHashMap]
 - FixedArray length: 17
 - elements: 1
 - deleted: 0
 - buckets: 2
 - capacity: 4
 - buckets: {
          0: -1
          1: 0
 }
 - elements: {
          0: 10 -> -10
 }

Poking around the v8 source, I find what I think to be the code related to OrderedHashTable and OrderedHashMap in src/objects/ordered-hash-table.cc. Specifically, line 368:

MaybeHandle<OrderedHashMap> OrderedHashMap::Add(Isolate* isolate,
                                            Handle<OrderedHashMap> table,
                                            Handle<Object> key,
                                            Handle<Object> value) {
...

After reading the code, my assumption is that OrderedHashMap::Add() will get triggered when you do Map.Prototype.Set (i.e., adding a new element). So I set a breakpoint here in and continue

gef➤  b v8::internal::OrderedHashMap::Add(v8::internal::Isolate*, 
v8::internal::Handle<v8::internal::OrderedHashMap>, 
v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>)
Breakpoint 1 at 0x557eb3b491e4
gef➤  c
Continuing.

I then attempt to set a new element, but the breakpoint does not trigger

d8> x.set(11,-11)
[object Map]

Breaking out into gdb again, it appears the element has been added

gef➤  job 0x346c0804ad35
0x346c0804ad35: [OrderedHashMap]
 - FixedArray length: 17
 - elements: 2
 - deleted: 0
 - buckets: 2
 - capacity: 4
 - buckets: {
              0: 1
              1: 0
 }
 - elements: {
              0: 10 -> -10
              1: 11 -> -11
 }

Do I have the breakpoint set up in the wrong spot? And if so, would anyone have any recommendations for efficiently finding the JS equivalents in v8?

How to align navbar item to bottom in bootstrap react?

Attachment

I have a bootstrap react sidebar(check attachment), but how would I go about aligning few items bottom-up way instead of top-down? In the attachment, I would like bottom two items(FAQ and Contact) lined up to bottom of screen.

<Nav className="flex-column pt-2">
      <p className="ml-3">Menus</p>

      <Nav.Item>
        <Nav.Link href="/">
          <FontAwesomeIcon icon={faTable} className="mr-2" />
          Dashboard
        </Nav.Link>
      </Nav.Item>

      <Nav.Item>
        <Nav.Link href="/">
          <FontAwesomeIcon icon={faWarehouse} className="mr-2" />
          Inventory
        </Nav.Link>
      </Nav.Item>

      <Nav.Item>
        <Nav.Link href="/">
          <FontAwesomeIcon icon={faTruck} className="mr-2" />
          Create Order
        </Nav.Link>
      </Nav.Item>

      <SubMenu
        title="Manage"
        icon={faCopy}
        items={["Sales", "Employees"]}
      />

     *//I want to put these two to bottom*
      <Nav.Item>
        <Nav.Link href="/">
          <FontAwesomeIcon icon={faQuestion} className="mr-2" />
          FAQ
        </Nav.Link>
      </Nav.Item>

      <Nav.Item className="align-items-end">
        <Nav.Link href="/">
          <FontAwesomeIcon icon={faPaperPlane} className="mr-2" />
          Contact
        </Nav.Link>
      </Nav.Item>


    </Nav>

uploading image to firebase using javascript

im trying to upload a image to firebase but im not sure of what im doing wrong when I run this I get error service is not available im not sure what im doing wrong im just following the documentation. I would really appreciate if someone took a look at this and tell me if im doing something wrong

 <script type="module">
    

    // TODO: Add SDKs for Firebase products that you want to use
    // https://firebase.google.com/docs/web/setup#available-libraries
      //Import the functions you need from the SDKs you need
    import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-app.js";
    import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.7/firebase-analytics.js";
    // Import the functions you need from the SDKs you need
    import { getStorage , ref , uploadBytes } from "https://www.gstatic.com/firebasejs/9.5.0/firebase-storage.js";
    
     
    function run(){

        // Your web app's Firebase configuration
        // For Firebase JS SDK v7.20.0 and later, measurementId is optional
        const firebaseConfig = {
        apiKey: "my details",
        authDomain: "my details",
        databaseURL: "my details",
        projectId: "my details",
        storageBucket: "my details",
        messagingSenderId: "my details",
        appId: "my details",
        measurementId: "my details"
        };
    
        // Initialize Firebase
        const firebaseApp = initializeApp(firebaseConfig);
        
        const storage = getStorage(firebaseApp);
        const storageRef = ref(storage, `upcomingTasks/hi.jpg`);


        // 'file' comes from the Blob or File API
        const file = document.getElementById("myimg").files[0];
        console.log("running")

        uploadBytes(storageRef, file).then((snapshot) => {
            console.log('Uploaded a blob or file!');
        });

        
    }
    

    window.onload(run())



</script>

Added execution time in discord.js bot console

I created a discord.js bot that works all the time. In the terminal where the bot is running I would like the running time of the bot since it started up to be displayed below “I am connected !”.

Here is part of my console code :

client.on('ready', () => {
      console.log('I am connected !');

Do you have any ideas ?

Thank you in advance for your help.