how to fix warning Circular dependency detected?

have a good time

I have about 10 errors a night when I start an angular project
And I do not understand what it means

How can I fix this error?

Warning: Circular dependency detected:
   srcapp@coredataservicesproject-managementprojectproject-target.service.ts -> 
   [email protected] -> srcappauthsecurity.service.ts -> 
   [email protected] -> 
   srcapp@coredataservicesproject-managementprojectproject-target.service.ts

enter image description here

Having issues using puppeteer on youtube

I’m trying to write a scraper using puppeteer that logs each superchat(and super thanks eventually) posted in a youtube videos live stream.

Here is my current code:

const puppeteer = require('puppeteer')
const fs = require("fs/promises")

async function start() {
    const browser = await puppeteer.launch()
    const page = await browser.newPage()
    await page.goto("https://www.youtube.com/watch?v=1ykh6t3mec0")

    const superchats = await page.evaluate(() => {
        return Array.from(document.querySelectorAll('#purchase-amount-chip')).map(x => x.textContent)
    })
    await fs.writeFile("superchats.txt", superchats.join('rn'))
    await browser.close()
}

start()

This seems to work on other websites but youtube is very odd. Not sure what the issue is to be honest.

I’m building netflix clone using reactjs.It is shownig the page for 1 sec and it turns blank again [duplicate]

 [import React, { useEffect, useState } from 'react';
 import './Row.css';
 import axios from './axios'

 function Row({ title,fetchUrl, isLargeRow = false}) {
    const [movies, setMovies] = useState([]);

    const base_url = "https://image.tmdb.org/t/p/original/"

    useEffect(() => {
        async function fetchData() {
            const request = await axios.get(fetchUrl);
            setMovies(request.data.results);
            return request;
        }

        fetchData();
}, [fetchUrl[]][1]);

// console.log(movies);

  return (
    <div className='row'>
        <h2>{title}</h2>

        {movies.map((movie) => (
             <img src={`${base_url}${
                isLargeRow ? movie.poster_path : movie.backdrop_path
            }`} alt={movie.name}
            />
            ))}
     </div>
  );
}

export default Row

I am getting an error

Warning: Each child in a list should have a unique “key” prop.

Check the render method of Row. See https://reactjs.org/link/warning-keys for more information.
at img
at Row (http://localhost:3000/static/js/bundle.js:596:5)
at div
at HomeScreen
at div
at App
at Provider (http://localhost:3000/static/js/bundle.js:43095:5)

How to push data in the setState of array-type state?

I am having a state data. I wanted to push a new entry of the form

{  task:'ANy task',key:Math.random().toString() }

in the data array while using setData.

I had tried many ways mentioned here, but don’t klnow why its not working.

Here’s my code.

import React, { useState } from "react";
import { StyleSheet, Text, View, TextInput, Button } from "react-native";
import { StatusBar } from "expo-status-bar";

const Addtask = ({navigation}) => {
 
  const [data,setData] = useState([]);

  console.log("from add = ",data)

  const [task, setTask] = useState("");


  const handleSubmit = () => {
    console.log("submit pressed for task = ", task)
    

    const updatedData = [...data,{
      task:task,
      key: Math.random().toString(),
    }]
    //here i am setting the data
    setData(prevState => [...prevState,updatedData]);
    console.log("data after adding task",data)
    
    navigation.navigate("Tasklist",{data:data})
  }

  return (
    <View style={styles.container}>
      <StatusBar style="light" backgroundColor="midnightblue" />
      <View>
        <Text style={styles.text}>Add Task Here</Text>
      </View>

      <View>
        <TextInput
          style={styles.input}
          onChangeText={setTask}
          value={task}
          onChange={setTask}
          placeholder="Type your task"
          keyboardType="ascii-capable"
        />
      </View>

      <View style={styles.buttoms}>
        <View style={{margin:4}}>
          <Button color={'red'} onPress={()=>{navigation.goBack()}} title="Cancel"></Button>
        </View>
        <View style={{margin:4}}>
          <Button color={'lightblue'} onPress={()=>setTask('')} title="Clear"></Button>
        </View>
        <View style={{margin:4}}>
          <Button color={'green'} onPress={handleSubmit} title="Save"></Button>
        </View>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  .
  .
  .
});
export default Addtask;

To debug, I had used console stmts which reveals that the task value is coming in the handleSubmit() correctly but it is not getting pushed.

Log

submit pressed for task =  Morning bike ride.
data after adding task Array []

Navigation bar stays hidden

I am create a simple navigation bar that runs along the top of the screen but when the display is under 768px it displays as a menu that can be closed with a click of a X or opened by click the Hamburger button.

I also have the site hosted on GitHub and the page can be loaded via here

Triggring events from react pusher js

I am trying to build a crypto exchange chart-based project and for that, I am using the pusher js library for my react app. I am able to receive data from the server because of the event but I am trying to send a message from front to my backend server and i don’t know how to send it from pusher js can anyone help me here’s my code:

FrontEnd

import React, { useEffect, useState } from "react";
import Pusher from "pusher-js";
import axios from "axios";

const App = () => {
  const [message, setMessage] = useState("");
  const [username, setUsername] = useState("");
  const [showErr, setShowErr] = useState("");

  useEffect(() => {
    const pusher = new Pusher("APP_KEY", {
    cluster: "APP_CLUSTER",
    encrypted: true,
  });
 const channel = pusher.subscribe("subscribe");
 channel.bind("my-event", (data) => {
   console.log(data);
  });
 return () => {
   pusher.unsubscribe("subscribe");
 };
}, []);

const sendMessage = (e) => {
  e.preventDefault();
  const channelName = "subscribe";
  if (message.trim().length > 0) {
    let data = {
      username,
      message,
    };
    setShowErr(false);
    axios
      .post(`http://localhost:5001/message?channel=${channelName}`, data)
      .then(() => {
        setMessage("");
      });
  } else setShowErr(true);
};

return (
<div>
  <form className="inputContainer" onSubmit={(e) => sendMessage(e)}>
  <input
      type="text"
      className="inputElement"
      value={username}
      onChange={(e) => setUsername(e.target.value)}
    />
    <input
      type="text"
      className="inputElement"
      value={message}
      onChange={(e) => setMessage(e.target.value)}
    />
    <button className="inputBtn" type="submit">
      Send
    </button>
    {showErr && <div className="errorText">Enter your message</div>}
  </form>
</div>
);
};

export default App;

BackEnd Code

const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
const Pusher = require("pusher");

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());

app.use("/static", express.static("public"));

app.get("/", (req, res) => {
  res.send("Welcome sir! hope your day is good.");
});

const pusher = new Pusher({
  appId: "APP_ID",
  key: "APP_KEY",
  secret: "APP_SECRET",
  cluster: "APP_CLUSTER",
  useTLS: true,
});

pusher.trigger("subscribe", "my-event", {
  message: "hello world",
});

app.post("/message", (req, res) => {
  const payload = req.body;
  pusher.trigger(req.query.channel, "my-event", payload);
  res.send(payload);
});

const port = 5001;

var server = app.listen(port, () =>
  console.log(`Server up and running on port ${port} !`)
);

I want to send a message from the socket, not from Axio’s request can anyone help me

Vertically center align text and icon in div [duplicate]

I have three rows of cards that contain text and an icon, but the icon refuses to vertically align in the div. Not sure what I’m missing. I’ve tried a lot of variations of styling in CSS to achieve this vertical centering but nothing has fixed it.

My code:

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="main.css" rel="stylesheet">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Epilogue:wght@400;500;700&display=swap" rel="stylesheet">

  <script src="https://code.iconify.design/2/2.2.1/iconify.min.js"></script>
</head>
<style>
  /* The Modal (background) */
  
  body {
    height: 100%;
    width: 100% !important;
    box-sizing: border-box;
    font-family: 'Epilogue', sans-serif;
  }
  
  .backRight {
    position: absolute;
    right: 0;
    width: 50%;
    height: 100%;
    background: url(/img/sidebanner1.png);
    background-size: cover;
    background-position: 50% 50%;
  }
  
  .backLeft {
    position: absolute;
    left: 0;
    width: 50%;
    height: 100%;
    background: url(/img/sidebanner3.png);
    background-size: cover;
    background-position: 50% 50%;
  }
  
  #back {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: -999;
  }
  
  #slideBox {
    width: 50%;
    max-height: 100%;
    height: 100%;
    overflow: hidden;
    margin-left: 50%;
    position: absolute;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  }
  
  .topLayer {
    width: 200%;
    height: 100%;
    position: relative;
    left: 0;
    left: -100%;
  }
  
  .left {
    width: 50%;
    height: 100%;
    background: #ffffff;
    left: 0;
    position: absolute;
  }
  
  .right {
    width: 50%;
    height: 100%;
    background: #ffffff;
    right: 0;
    position: absolute;
  }
  
  .content1 {
    width: 250px;
    margin: 0 auto;
    top: 30%;
    position: absolute;
    left: 50%;
    margin-left: -125px;
  }
  
  .content1 h2 {
    color: black;
    font-weight: 300;
    font-size: 35px;
  }
  
  .content2 {
    width: 350px;
    margin: 0 auto;
    top: 20%;
    position: absolute;
    left: 50%;
    margin-left: -150px;
  }
  
  .content1 h2 {
    color: black;
    font-weight: 300;
    font-size: 35px;
  }
  
  .mobileContent {
    overflow: visible;
    width: 350px;
    margin: 0 auto;
    top: 20%;
    position: relative;
    left: 50%;
    margin-left: -150px;
  }
  
  .mobileContent h2 {
    overflow: visible;
    color: black;
    font-weight: 300;
    font-size: 35px;
  }
  
  button {
    background: black;
    padding: 10px 16px;
    width: 250px;
    font-weight: 500;
    font-size: 14px;
    color: #fff;
    line-height: 16px;
    letter-spacing: 0.5px;
    border-radius: 10px;
    border: 0;
    outline: 0;
    margin: 15px 15px 15px 0;
    transition: all 0.25s;
    cursor: pointer;
  }
  
  button:hover {
    background: #ff0000;
    cursor: pointer;
  }
  
  .off {
    background: none;
    color: black;
    cursor: pointer;
  }
  
  #membershipOption {
    vertical-align: middle;
  }
  
  #membershipOption:hover {
    background-color: red;
    color: white;
    cursor: pointer;
    transition: .2s ease-in;
  }
</style>
<div style="padding: 10%;" align="center">

  <br><br><br><br>

  <a href="signup-monthly.html" style="text-decoration: none; color: black;">
    <div class="card" id="membershipOption">
      <div class="card-body">
        <div class="row">
          <div class="col-8" align="left">
            <div class="sidebyside">
              <div class="sidebysidealign">
                <span style="font-size: large;">Month-To-Month</span>
                <br>
                <span>$15/month</span>
              </div>
            </div>
          </div>
          <div class="col-4" align="right" style="display:table-cell">
            <div class="sidebysidealign justify-content-center">
              <span class="iconify sidebysidearrow" data-icon="bi:arrow-right-circle" style="font-size: 25px; height: auto; vertical-align:middle; padding-top: 15%;"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </a>

  <br>

  <a href="signup-annual.html" style="text-decoration: none; color: black;">
    <div class="card" id="membershipOption">
      <div class="card-body">
        <div class="row">
          <div class="col-8" align="left">
            <div class="sidebyside">
              <div class="sidebysidealign">
                <span style="font-size: large;">
                                Annual
                                <br>
                                $120/year</span>
              </div>
            </div>
          </div>
          <div class="col-4" align="right" style="display:table-cell">
            <div class="sidebysidealign justify-content-center">
              <span class="iconify sidebysidearrow" data-icon="bi:arrow-right-circle" style="font-size: 25px; height: auto; vertical-align:middle; padding-top: 15%;"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </a>

  <br>

  <a href="signup-annual.html" style="text-decoration: none; color: black;">
    <div class="card" id="membershipOption">
      <div class="card-body">
        <div class="row">
          <div class="col-8" align="left">
            <div class="sidebyside">
              <div class="sidebysidealign">
                <span style="font-size: large;">
                                    Enterprise
                                    <br>
                                    <span style="font-size: small;">Company with 50+ employees.</span>
                </span>
              </div>
            </div>
          </div>
          <div class="col-4" align="right" style="display:table-cell">
            <div class="sidebysidealign justify-content-center">
              <span class="iconify sidebysidearrow" data-icon="bi:arrow-right-circle" style="font-size: 25px; height: auto; vertical-align:middle; padding-top: 15%;"></span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </a>
  <br><br>
  <p>Already have an account? <span id="goRight" class="off"><u>Login</u></span></p>
</div>

Would like to learn what I’m missing. Thanks.

React Native Navigation: Authentication Flow not update after fetching Token

In my authentication flow the user should be redirected to the Home Screen after they have fetched the token from the API and if they logout it should redirect them back to the Login Screen. Unfortunately, it doesn’t do that. I had to hot restart the app, & then it redirects to the correct screen.

App.js

const App = () => {
  const [token, setToken] = React.useState(false);

  useEffect (() => {
    getData();
  });

  const getData = async () => {
    const value = await AsyncStorage.getItem('@user_auth');
    if(value !== null) {
      setToken(true);
    }
  }
  
  return (
    <NavigationContainer>
      {token == false ? (
        <Stack.Navigator initialRouteName="LoginScreen" screenOptions={{headerShown: false}}>
          <Stack.Screen name="LoginScreen" component={LoginScreen} />
          <Stack.Screen name="RegistrationScreen" component={RegistrationScreen} />
        </Stack.Navigator>
      ) : (
        <Stack.Navigator initialRouteName="HomeScreen" screenOptions={{headerShown: false}}>
          <Stack.Screen name="HomeScreen" component={HomeScreen} />
        </Stack.Navigator>
      )}
      
    </NavigationContainer>
  );
};

LoginScreen

const storeData = async (accessToken, tokenType) => {
        try {
            await AsyncStorage.setItem('@access_token', accessToken);
            await AsyncStorage.setItem('@token_type', tokenType);
            await AsyncStorage.setItem('@user_auth', tokenType + " " + accessToken);
        } catch (e) {
          console.log(e);
        }
    }

    const _userLogin = () => { 
        fetch(URLs._login, {
            method: "POST",
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json',
            },
            body: JSON.stringify({
                email: inputs.email,
                password: inputs.password,
            })
        }).then((response) => response.json())
        .then(async (result) => {console.log(result);
            if(result.message !== "Unauthorized / Access Token Expired" && result.message !== "The given data was invalid."){
                storeData(result.access_token, result.token_type)
            } else {
                Alert.alert("Error", result.message);
            }
        });
    };

CustomModal.js (User press on a modal to logout)

const [inputs, setInputs] = React.useState({
        userAuth: '',
    });

    useEffect (() => {
        getData();
    }, []);

    const getData = async () => {
        inputs.userAuth = await AsyncStorage.getItem('@user_auth');
        //console.log("retrive");
    }

    const _logout = () => {
        fetch(URLs._logout, {
            method: "GET",
            headers: {
                'Authorization': inputs.userAuth,
                'Content-Type': 'application/json',
              },
        }).then((response) => response.json())
        .then((result) => {
            console.log(result);
            if(result.message == "Successfully logged out"){
                AsyncStorage.clear();
                navigation.popToTop();
            }
            Alert.alert("Logout", result.message);
        });
    };

    const logoutAlert = () => {
        Alert.alert(
          "Logout",
          "Do you want to logout?",
          [
            {text: 'Yes', onPress: () => _logout()},
            {text: 'No', onPress: undefined, style: 'cancel'},
          ],
          { 
            cancelable: true 
          }
        );
    }

Cannot read properties of undefined (reading ‘voiceAdapterCreator’)

i had using Discord.js v13.6.0 and i had defined -connection command to make bot join to msg.user voice channel dynamically and i got some errors on adapterCreator and i need help how i can do it

this is my code

if (msg.content === '${prefix}connect') {
       const { joinVoiceChannel } = require('@discordjs/voice');
       const connection = joinVoiceChannel({
            channelId: defaultConfig.channelId,
            guildid: defaultConfig.guildID,
            adapterCreator: channel.guild.voiceAdapterCreator,
        });
        channel.join(connection);
}

and it’s Appearing

/home/gitpod/.nvm/versions/node/v16.15.0/bin/node ./index.js
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.10.0-dev
- prism-media: 1.3.2

Opus Libraries
- @discordjs/opus: 0.5.3
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: 3.0.2
- libsodium-wrappers: 0.7.10
- tweetnacl: not found

FFmpeg
- version: 4.4.1-static https://johnvansickle.com/ffmpeg/ 
- libopus: yes
--------------------------------------------------
AxiosError {message: 'Request failed with status code 404', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: ClientRequest, …}
PKS4.1Bot#5240 Bot States: Online
Process exited with code 1
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'voiceAdapterCreator')
    at <anonymous> (/workspace/DeltCrosXDiscordTools/index.js:202:43)
    at emit (node:events:527:28)
    at handle (/workspace/DeltCrosXDiscordTools/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
    at module.exports (/workspace/DeltCrosXDiscordTools/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at handlePacket (/workspace/DeltCrosXDiscordTools/node_modules/discord.js/src/client/websocket/WebSocketManager.js:346:31)
    at onPacket (/workspace/DeltCrosXDiscordTools/node_modules/discord.js/src/client/websocket/WebSocketShard.js:478:22)
    at onMessage (/workspace/DeltCrosXDiscordTools/node_modules/discord.js/src/client/websocket/WebSocketShard.js:317:10)
    at onMessage (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/event-target.js:199:18)
    at emit (node:events:527:28)
    at receiverOnMessage (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/websocket.js:1169:20)
    at emit (node:events:527:28)
    at dataMessage (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/receiver.js:528:14)
    at getData (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/receiver.js:446:17)
    at startLoop (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/receiver.js:148:22)
    at _write (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/receiver.js:83:10)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at Writable.write (node:internal/streams/writable:334:10)
    at socketOnData (/workspace/DeltCrosXDiscordTools/node_modules/ws/lib/websocket.js:1263:35)
    at emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Readable.push (node:internal/streams/readable:228:10)
    at onStreamRead (node:internal/stream_base_commons:190:23)
    at callbackTrampoline (node:internal/async_hooks:130:17)

Accessing a div a button is wrapped in when button is pressed

I’m currently designing a website that loads in a list of available items. I’m using EJS to dynamically load the items in from a database and displaying them in separate divs. However, I want the user to be able to select one of the items from the list. I’ve added a button to each of the divs, but I’m not sure how to make it so that when a button is pressed, it accesses the div it is nested in.

The code is below


    <%for(var i = 0; i<groups.length; i++){%>
    <div class="col-md-4">
      <div class="card rider-card">
        <div class="card-body">
          <h4 class="card-title">Text Here</h4>
          <h5 class="card-subtitle mb-2 text-muted">Text Here</h5>
          <h6 class="card-text">___ spots available</h6>
          <p class="card-text">Text Here</p>
          <a onclick="selectDriver()" class="stretched-link"></a>
        </div>
      </div>
    </div>
    <%}%>

I’m using MongoDB to store the data in the database, and calling the collection as groups. I iterate through the groups and create a new card for each one. Because I’m dynamically generating the divs, I can’t seem to find a way to differentiate them. The button is the anchor tag, which applies to the entire card.

Is there a way to access only the card the anchor tag is nested in?

how to create in mysql a date and time column with a correct format to display in the browser?

I am trying to create a table in MySql with a date and time column in which I put the TIMESTAMP data type with a default value of CURRENT_TIMESTAMP but it returns an incorrect format like this

2022-06-12T00:36:20.000Z

(I HAVE ALSO TRIED TO USE THE DATETIME DATA TYPE, IT RETURNS THE SAME THING)

instead of returning the date and time in the correct format as shown in a select CURRENT_TIMESTAMP of the terminal, it returns something like this and with 3 HOURS IN ADVANCE, how could I solve this?

CREATE TABLE mensajes (
  id INTEGER UNSIGNED PRIMARY KEY AUTO_INCREMENT,
  email VARCHAR(100) NOT NULL,
  msg TEXT NOT NULL,
 `date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO mensajes (email,msg) VALUES('[email protected]','Hello World');