What is the problem with my code(bandwidth limitation)?

I’m now making a broadcasting web using socket.io and webRTC. I can successly broadcast the video stream from the broadcaster to the viewers. However, I want to limit the bandwidth of the viewers/broadcasters so that if more viewers/broadcaster join the server, the quality of the video can be reduced to allow more users. It seems that I cannot change the videoWidth and videoHeight as they are read-only so I cannot directly change the resolution of the video. So I wonder if I can setBitrate to limit the performance of the video.

server.js

const express = require("express");
const app = express();

let broadcaster;
const port = 4000;

const http = require("http");
const server = http.createServer(app);

const io = require("socket.io")(server);
app.use(express.static(__dirname + "/public"));

io.sockets.on("error", e => console.log(e));
io.sockets.on("connection", socket => {
  socket.on("broadcaster", () => {
    broadcaster = socket.id;
    socket.broadcast.emit("broadcaster");
  });
  socket.on("watcher", () => {
    socket.to(broadcaster).emit("watcher", socket.id);
  });
  socket.on("offer", (id, message) => {
    socket.to(id).emit("offer", socket.id, message);
  });
  socket.on("answer", (id, message) => {
    socket.to(id).emit("answer", socket.id, message);
  });
  socket.on("candidate", (id, message) => {
    socket.to(id).emit("candidate", socket.id, message);
  });
  socket.on("disconnect", () => {

    if (socket.id === broadcaster) {
      
      socket.broadcast.emit("disconnectServer");
    }
    
    socket.broadcast.emit("disconnectPeer", socket.id);
  });
});
server.listen(port, () => console.log(`Server is running on port ${port}`));

broadcast.js

const peerConnections = {};
const config = {
  iceServers: [
    {
      "urls": "stun:stun.l.google.com:19302"
    }
  ],
  sdpSemantics: "plan-b"
};

function setBitrate(sdp, bitrate) {
  return sdp.replace(/a=mid:(audio|video)rn/g, `a=mid:$1rnb=AS:${bitrate}rn`);
}



const socket = io.connect(window.location.origin);
const video = document.querySelector("video");


// Media contrains
function getStream() {
  if (window.stream) {
    window.stream.getTracks().forEach(track =>{
      track.stop();
    });
  }
  const constraints = {
    video: true,
    audio: true,
    width: {exact:320},
    height: {exact:240},
    aspectRatio: 16/9,
    frameRate: {exact: 30},
    videoBitrate: 100000
    
  };

  

  
  navigator.mediaDevices.getUserMedia(constraints)
    .then(stream => {
      const videoTrack = stream.getVideoTracks()[0];
      const capabilities = videoTrack.getCapabilities();
      console.log(capabilities.width.max); // maximum supported width
      console.log(capabilities.height.max); // maximum supported height
    })
    .catch(error => {
      // handle the error
    });
  video.addEventListener("loadedmetadata", function(){
    console.log("VideoWidth: " + video.videoWidth + " VideoHeight: " + video.videoHeight);
  })


  return navigator.mediaDevices
    .getUserMedia(constraints)
    .then(gotStream)
    .catch(handleError);
}




function gotStream(stream){ 
  window.stream = stream;
  video.srcObject = stream;
  socket.emit("broadcaster");
}



function handleError(error) {
  console.error("Error: ", error);
}


function setdefaultscreen(){
  video.srcObject = null;
  video.style.backgroundColor = "black";
}

socket.on("watcher", id => {
  console.log("viewerConnect!!");
  const peerConnection = new RTCPeerConnection(config);
  peerConnections[id] = peerConnection;

  let stream = video.srcObject;
  stream.getTracks().forEach(track => peerConnection.addTrack(track, stream));
    
  peerConnection.onicecandidate = event => {
    if (event.candidate) {
      socket.emit("candidate", id, event.candidate);
    }
  };

  peerConnection
    .createOffer()
    .then(sdp => {
      sdp.sdp = setBitrate(sdp.sdp, 5);
      return peerConnection.setLocalDescription(sdp)})
    .then(() => {
      socket.emit("offer", id, peerConnection.localDescription);
    });
});

socket.on("answer", (id, description) => {
  peerConnections[id].setRemoteDescription(description);
});

socket.on("candidate", (id, candidate) => {
  peerConnections[id].addIceCandidate(new RTCIceCandidate(candidate));
});

socket.on("disconnect" ,() =>{
  socket.emit("disconnect");
  console.log("disconnect from server");
  if (peerConnection) {
    peerConnection.close();
  }
  setdefaultscreen();
})

socket.on("disconnectPeer", id => {
  console.log("disconnect peer from client");
  peerConnections[id].close();
  delete peerConnections[id];
});


window.onunload = window.onbeforeunload = () => {
  socket.close();
};


getStream();

viewer.js

let peerConnection;
const config = {
  iceServers: [
      { 
        "urls": "stun:stun.l.google.com:19302",
      },
      // { 
      //   "urls": "turn:TURN_IP?transport=tcp",
      //   "username": "TURN_USERNAME",
      //   "credential": "TURN_CREDENTIALS"
      // }
  ],
  sdpSemantics: "plan-b",
};


function setBitrate(sdp, bitrate) {
  return sdp.replace(/a=mid:(audio|video)rn/g, `a=mid:$1rnb=AS:${bitrate}rn`);
}

const socket = io.connect(window.location.origin);
const video = document.querySelector("video");

socket.on("offer", (id, description) => {
  peerConnection = new RTCPeerConnection(config);
  peerConnection
    .setRemoteDescription(description)
    .then(() => peerConnection.createAnswer())
    .then(sdp => {
      sdp.sdp = setBitrate(sdp.sdp, 5);
      return peerConnection.setLocalDescription(sdp)}
      )
    .then(() => {
      socket.emit("answer", id, peerConnection.localDescription);
    });
  peerConnection.ontrack = event => {
    video.srcObject = event.streams[0];
  };
  peerConnection.onicecandidate = event => {
    if (event.candidate) {
      socket.emit("candidate", id, event.candidate);
    }
  };
});


socket.on("candidate", (id, candidate) => {
  peerConnection
    .addIceCandidate(new RTCIceCandidate(candidate))
    .catch(e => console.error(e));
});

socket.on("connect", () => {
  socket.emit("watcher");
});

socket.on("broadcaster", () => {
  
  socket.emit("watcher");
});

function setdefaultscreen(){
  video.srcObject = null;
  video.style.backgroundColor = "black";
}

socket.on("disconnectServer", () => {
  console.log("disconnect from server");
  setdefaultscreen();
});

window.onunload = window.onbeforeunload = () => {
  socket.close();
  peerConnection.close();
  setdefaultscreen();
  
  
};

now I setBitrate to 5 and the video should be hardly playable. But I found that no matter what value I set the video is still playable and its quality doesn’t change. I use Google Chrome to open the web. Is the problem related to the browser?

not able to modify javascript object which i get from input tag

i am trying to make upload functionality in my e-commerce website and in my html i have created
<input type="file" id="file" accept=".jpg, .png, .jpeg, .svg, .jfif, pjpeg, pjp" multiple><br> which gives me a object of items and i am trying to modify the files name within this object but couldn’t able to do that please help

HTML

<form id="form">
        <input type="text" id="title" placeholder="Product Name"><br>
        <input type="number" id="price" placeholder="Price"><br>
        <textarea id="description" placeholder="Description" name="description" rows="4" cols="50"></textarea><br>
        <input type="file" id="file" accept=".jpg, .png, .jpeg, .svg, .jfif, pjpeg, pjp" multiple><br>
        <button type="submit">Upload File</button>
    </form>

JS

const button = document.querySelector("form").addEventListener('submit',(e)=>{
    e.preventDefault();
    let userFiles = document.getElementById("file").files;
    
    let i = 1;
    for (let element of userFiles) {
        // console.log(element.type)
        let extension = element.type.slice(6,element.type.length+1);
        console.log("user_file"+i+"."+extension);
        element.name = "user_file"+i+"."+extension;
        console.log(element["name"]);
        i++;
    }
 

});

i want to change the name of uploaded files in the format “user_filei.extension”

Hello. i need help in my JS cart file, the values are neither incrementing nor decrementing

I tried in so many ways even watching on youtube on how to fix it, but to no avail. am new to programming.

HTML
<div class="input-group number-spinner"> <button id="phone-minus" class="btn-default"><i class="fa-solid fa-minus"></i></button> <input type="number" id="phone-number" value="0" class="form-control text-center" value="1"> <button id="phone-plus" class="btn btn-default"><i class="fas fa-plus"></i></button> </div>

JS file
`function updateProductNumber(product, price, isIncreasing) {
const productNumber = document.getElementById(product + ‘phone-number’);
let productValue = parseInt(productNumber.value);
if (isIncreasing) {
productValue = productValue + 1;
} else if (productValue > 0) {
productValue = productValue – 1;
}
productNumber.value = productValue;

// Update product total
const productTotal = document.getElementById(product + '-total');
productTotal.innerText = productValue * price;
calculateTotal();
}

function getElementValue(product) {
const productInput = document.getElementById(product + '-number');
const productValue = parseInt(productInput.value);
return productValue;
}

function calculateTotal() {
const phoneTotal = getElementValue('phone') * 1219;
const caseTotal = getElementValue('case') * 59;
const subTotal = phoneTotal + caseTotal;
const tax = subTotal / 10;
const totalPrice = subTotal + tax;

// Update HTML elements
document.getElementById('sub-total').innerHTML = subTotal;
document.getElementById('tax-amount').innerHTML = tax;
document.getElementById('total-price').innerHTML = totalPrice;
}
document.getElementById('case-plus').addEventListener('click', function() {
updateProductNumber('case', 59, true);
});
document.getElementById('case-minus').addEventListener('click', function() {
updateProductNumber('case', 59, false);
});
document.getElementById('phone-plus').addEventListener('click', function() {
updateProductNumber('phone', 1219, true);
});
document.getElementById('phone-minus').addEventListener('click', function() {
updateProductNumber('phone', 1219, false);
});

`

Replace strings in dynamically loaded content with Javascript?

I used this piece of code, to replace text strings in my webpage:

   function walkText(node) {
      if (node.nodeType == 3) {
        node.data = node.data.replace(/Villa/g, "Replaced");
        node.data = node.data.replace(/Apartment/g, "Replaced2");
      }
      if (node.nodeType == 1 && node.nodeName != "SCRIPT") {
        for (var i = 0; i < node.childNodes.length; i++) {
          walkText(node.childNodes[i]);
        }
      }
    }
    walkText(document.body);
Villa
Apartment

This works fine on static content, but will not work on content that gets loaded dynamically through ajax. Is there a workaround to make this work on text that is not static/not loaded on page load?

Thanks.

How to add motion blur to the moving object

I am using translate property to make a custom mouse move on the document based on the x and y coordinates of the mouse. Now I want to add a little motion blur effect to the custom moving object in order to make it look smooth and good.

document.onmousemove = function(event) {
    
    cursor.style.transform = `translate(${event.clientX}px, ${event.clientY}px)`
}
.cursor {
    -webkit-tap-highlight-color: transparent;
    position: fixed;
    left: -8px;
    top: -6px;
    pointer-events: none;
    user-select: none;
    transition-duration: .12s;
    transition-timing-function: ease-out;
    transform: translate(0, 0);
    will-change: transform;
    /* filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8)); */
    z-index: 999999999999999999999999999;
    svg {
        display: block;
        width: 40px;
        height: 40px;
        
    }
}

Testing redux saga’s selector and dispatch in a component

is there a way to test this case?
for example:
This is my component:

import React, { useEffect } from 'react'
import { useDispatch } from 'react-redux'
import { useNavigate } from 'react-router-dom'
import { useAppSelector } from '../../../redux/store'
import { ProfileTypes } from '../../../views/apps/settings/profile/store/type'

const Test = () => {
  const dispatch = useDispatch()
  const DetailSlice = useAppSelector((state: any) => state.ProfileSlice.userDetails)
  const navigate = useNavigate()

  useEffect(() => {
    dispatch({
      type: ProfileTypes.GET_USER_DETAILS,
    })
  }, [])
  return (
    <div>
      {DetailSlice}
      <button onClick={() => navigate('/details')}>Go To Details</button>
    </div>
  )
}

export default Test


I want to test it with 100% line coverage, but i couldnt make it.

How to use value of useState using react testing library

const SettingsContainer = () => {
    const [settingsData, setSettingsData] = useState({})

    const { show_abe = false, show_def = false } = settingsData;

    const refreshSettings = () => {
        getSettings().then((resp) => {
            setSettingsData(resp.data);
        });
    };

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

    return (
        <div>
            {show_abe ? 
                <abc></abc> : null
            }
            {show_def ? 
                <def></def> : null
            }
        </div>
    )
}

export default SettingsContainer;

tried below test case

    const respData = { show_cobranding: true, allowGenerateApiToken: true, cloud_key_management: true, enterprise_key_management: true, show_mdeploy_setting: true };

    jest.mock('../../hooks/apis', () => ({
        getSettings: jest.fn(() => Promise.resolve({ data: { respData } })),
        
    }));

    describe('SettingsContainer', () => {
        beforeEach(() => {
            render(<HashRouter><SettingsContainer /></HashRouter>);
        });

        test('Should Display Page Heading', () => {
            expect(screen.getByText('Settings')).toBeInTheDocument();
        });

        test('Check if child component has been loaded or not', async () => {
            await waitFor(() => {
                expect(screen.getByTestId('abc')).toHaveTextContent('ABC');
                expect(screen.getByTestId('def')).toHaveTextContent('DEF');
        })});
    });

How to write a test case to show abc component and def which I receive from API call and I set that data in state using useState, using React Testing Library?

Tree Structure for JSON data sorted by parameter “level”

I have to make a view that shows data in tree structure in Javascript with rolling down lower levels. Every object with level 1 should roll down on click elements with level 2 between its and next level 1 object. Level 2 should roll down level 3 objects under him etc. Of course if other levels exists. Is there any ready grid or library for that? Here is how my data look:

https://i.stack.imgur.com/SYdeg.png

How to remove additional header in react native?

When I added navigation, suddenly I have two headers. How do I remove the “index” header.

index.js:

import { useState, useEffect } from 'react';
import { View, ScrollView, SafeAreaView, Text, Button, StatusBar } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack'

import Home from './home';
import styles from '../myComponents/common/header/header/header.style';
import { COLORS, icons, images, FONT, SIZES } from '../constants';
import { ScreenHeaderBtn, TimeSlider, SessionBtn } from '../myComponents';

const Stack = createNativeStackNavigator();

function App() {
    return (
        <NavigationContainer independent={true}>
            <Stack.Navigator>
                <Stack.Group screenOptions={{
                        headerStyle: { backgroundColor: COLORS.lightBeige },
                        headerShadowVisible: true,
                        headerLeft: () => (
                            <ScreenHeaderBtn iconUrl={icons.menu} dimension="60%" />
                        ),
                        headerTitle: () => (
                            <Text style={styles.headerStyle}>
                                Flowtime
                            </Text>
                        ),
                        headerTitleAlign: 'center',
                    }}>
                    <Stack.Screen name="Home" component={Home} />
                </Stack.Group>
            </Stack.Navigator>
        </NavigationContainer>
    );
};

export default App;

home.js

import { useState, useEffect } from 'react';
import { View, ScrollView, SafeAreaView, Text, Button } from 'react-native';

import styles from '../myComponents/common/header/header/header.style';
import { COLORS, icons, images, FONT, SIZES } from '../constants';
import { ScreenHeaderBtn, TimeSlider, SessionBtn } from '../myComponents';

function Home() {
    return (
        <SafeAreaView style={{ flex: 1, backgroundColor: COLORS.lightBeige }}>
            <ScrollView showsVerticalScrollIndicator={false}>
                <View style={{ flex: 1, padding: SIZES.medium, }}>

                    <View style={{ alignItems: 'center', padding: SIZES.xLarge }}>
                        <SessionBtn />
                    </View>
                    <View style={{ alignItems: 'center', padding: SIZES.xLarge }}>
                        <TimeSlider />
                    </View>

                </View>
            </ScrollView>
        </SafeAreaView>
    );
};

export default Home;

Screenshot

If I remove independent={true} from the NavigationContainer I get this:

“Error: Looks like you have nested a ‘NavigationContainer’ inside another. Normally you need only one container at the root of the app, so this was probably an error. If this was intentional, pass ‘independent={true}’ explicitly. Note that this will make the child navigators disconnected from the parent and you won’t be able to navigate between them.”

So I believe I need to find the other supposed another NavigationContainer and place an options={{headerShown:false}} within it but the problem is that this NavigationContainer is the only one I put in my entire project. So I have no idea how else to get this other “index” header above my intended to disappear… Perhaps the additional header is caused by the phantom NavigationContainer and in that case, how can I find it and remove it, cause I literally just installed NavigationContainer and implemented a total of one NavigationContainer yet I am getting this error that this NavigationContainer is inside another which sounds impossible.

Elements act like they are in focus when they aren’t

I have some HTML and CSS code, but for some reason, my input box and span think that they are in focus. I’ve tested it out with debug prints, and they aren’t in focus, but they still act like it. I don’t understand why this is. Any help is appreciated

Screenshot of issueenter image description here

index.html

<!doctype html>
<html lang="en">

<head>
    <title>Log in</title>
    <link rel="stylesheet" href="/styles.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>

<body>
    <div class="signup" id="signup-div">
        <div id="below-signup">
            <span>
                <p class="signtext">Sign in</p>
            </span>
            <form>
                <div class="inputBox">
                    <input name="username" type="text" id="username-box">
                    <span>Phone, email, or username</span>
                </div>

                <span>
                    <button type="submit" name="btn-next" id="btn-next" class="next">Next</button>
                </span>
            </form>

            <div class="loader" id="load"></div>

            <span>
                <button class="forgot">Forgot password?</button>
            </span>

            <span class="create">
                <p>Don't have an account? <a href="/signup">Sign up</a></p>
            </span>

        </div>

        <div class="no-account-found">
            <span>
                <p id="no-found">Sorry, we could not find your account.</p>
            </span>
        </div>
    </div>

    <script>
        
        
    </script>

    <script>
        $("#btn-next").on("click", function(e) {
            e.preventDefault();
            document.getElementById("below-signup").style.visibility = "hidden";
            document.getElementById("load").style.visibility = "visible";
            document.getElementById("load").style.animationPlayState = "running";
            const username_data = document.getElementById("username-box").value;
            const request = new XMLHttpRequest();
            request.open('GET', `/validate_account?account=${username_data}`, true)
            request.onload = () => {
                document.getElementById("below-signup").style.visibility = "visible";
                document.getElementById("load").style.visibility = "hidden";
                document.getElementById("load").style.animationPlayState = "paused";
                const results = JSON.parse(request.responseText);
                if (results[0] == 1) {
                    
                } else {
                    document.getElementById('username-box').value = ''
                    document.getElementById("no-found").style.visibility = "visible";

                    setTimeout(function(){
                        document.getElementById("no-found").style.visibility = "hidden";
                    }, 4000);
                }
            }

            request.send()
    
        });
    </script>

</body>



</html>

styles.css


*
{
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif
}

.signup {
    border: 5px solid;
    position: absolute;
    height: 600px;
    width: 500px;
    top: 50%;
    border-radius: 18px;
    background-color: #010100;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px;
}

.signtext {
    color: white;
    font-weight: 650;
    font-size: 30px;
    position: relative; left: 115px; top: 10px;
    letter-spacing: 1px;
    text-align: justify;
}

body {
    background-color: #252d35;
    overflow-x: hidden;
}

.inputBox {
    position: relative; left: 113px; top: 15px;
    width: 250px;
    float:left;
    height: 50px;

}

.inputBox input {
    width: 100%;
    height: 100%;
    padding: 10px; /* Make text stick to bottom (Smaller input?) */
    border: 1px solid rgba(255,255,255,0.25);
    background: #010100;
    border-radius: 7px;
    outline: none;
    color: #fff;
    font-size: 1em;
}

.inputBox span 
{
    position: absolute; top: 15px;
    left: 0;
    padding: 10px;
    pointer-events: none;
    font-size: 18px;
    color: rgba(255,255,255,0.25);
    transition: 0.15s;
}

.inputBox input:valid ~ span,
.inputBox input:focus ~ span
{
    color: #1d9af1;
    transform: translateX(1px) translateY(-10px);
    font-size: 0.8em;
    padding: 0 10px;
    background: #010100;
}
.inputBox input:valid,
.inputBox input:focus
{
    border: 1px solid #1d9af1;
}

.next {
    border: none;
    color: black;
    font-weight: 650;
    height: 40px;
    width: 275px;
    position: relative; top: 60px; left: 112px;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 500px;
}

.create-account {
    border: none;
    color: black;
    font-weight: 650;
    height: 40px;
    width: 275px;
    position: relative; top: 20px; left: 112px;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 500px;
}

.forgot {
    border: none;
    color: white;
    background-color: #010100;
    font-weight: 650;
    height: 40px;
    border: 2px solid rgba(255,255,255,0.25);
    width: 275px;
    position: relative; top: 85px; left: 112px;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 500px;
}

.next:hover {
    background-color: #d6dbdd;
    transition: 0.15s;
}

.create-account:hover {
    background-color: #d6dbdd;
    transition: 0.15s;
}

.forgot:hover {
    background-color: #191919;
    transition: 0.15s;
}

.create p {
    color: #64696c;
    font-size: 16px;
    position: relative; top: 130px; left: 115px;
}

.login p {
    color: #64696c;
    font-size: 16px;
    font-weight: 400;
    position: relative; top: 50px; left: 115px;
}

.login a {
    color: #1d9af1;
    font-size: 16px;
    font-style: normal;
    text-decoration:none;
}

.login a:hover {
    text-decoration: underline;
    cursor: pointer;
}

.rules p {
    color: #64696c;
    font-size: 13px;
    font-weight: 400;
    position: relative; top: 20px; left: 115px;
}

.rules a {
    color: #1d9af1;
    font-size: 13px;
    font-style: normal;
    text-decoration:none;
}

.rules a:hover {
    text-decoration: underline;
    cursor: pointer;
}

.create a {
    color: #1d9af1;
    font-size: 16px;
    font-style: normal;
    text-decoration:none;
}

.create a:hover {
    text-decoration: underline;
    cursor: pointer;
}

.header {
    top: 0;
    position: fixed; 
    background-color: white;
    padding-bottom: 80px;
    padding-top: 20px;
    padding-left: 1920px;
    padding-right: 10px;
    overflow: hidden;
    z-index: 99;
}

.tos-header {
    font-weight: 650;
    font-size: 20px;
    position: fixed; left: 51px;
}


.no-margin {
    margin: 0;
    height: 20000px;
    min-width: 1920px;
}

.background-tos img {
    position: relative;
    pointer-events: none;
    z-index: 10;
}

.background-tos h1 {
    position: relative;
    bottom: 700px;
    left: 50px;
    font-size: 144px;
    color: #15171b;
    z-index: 11;
}

.effective {
    position: absolute; 
    background-color: #15171b;
    padding-bottom: 95px;
    bottom: -17px;
    padding-top: 200px;
    padding-left: 1920px;
    padding-right: 10px;
}

.effective-text {
    color: white;
    font-weight: 750;
    position: absolute; bottom: 15px; left: 820px; 
    text-align: center;
}

.tos-list ol {
    position: relative; left: 250px;
    bottom: 450px;
    list-style-type: none;
}

.tos-list a {
    color:#010100;
    text-decoration: none;
    font-weight: 700;
    word-wrap: break-word;
    white-space: normal;
    float: left;
}

.tos-list a:hover {
    color: #36414b;
}

.tos-one {
    position: relative; bottom: 300px; left: 800px;
}

.tos-two {
    position: relative; bottom: 200px; left: 800px;
}

.tos-text {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.2rem;
    overflow-wrap: break-word;
}

#tos-one {
    position: relative; left: 800px; bottom: 250px;
}

.no-account-found p {
    color: white;
    background-color: #1d9af1;
    border: 15px solid #1d9af1;
    display: inline-flex;
    position: relative; top: 420px; left: 100px;
    border-radius: 5px;
    visibility: hidden;
    margin: 0;
    padding: 0;
}

.loader {
    position: absolute; left: 240px; 
    visibility: hidden;
    margin: 0;
    bottom: 300px;
    border: 5px solid rgba(30, 153, 241, 0.61);
    border-radius: 50%;
    border-top: 5px solid #1d9af1;
    width: 25px;
    height: 25px;
    animation: spinner 0.70s linear infinite;
    animation-play-state: paused;
  }
  
  @keyframes spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

#step0 {
    display: relative;
}

#step1 {
    display: none;
}

.step-text {
    color: white;
    font-weight: 650;
    font-size: 25px;
    line-height: 24px;
    position: relative; left: 25px; bottom: 550px;
    letter-spacing: 1px;
}

.create-text {
    color: white;
    font-weight: 650;
    font-size: 30px;
    line-height: 24px;
    position: relative; left: 110px; bottom: 480px;
    letter-spacing: 1px;
}

A lot of the stuff in my styles.css relates to other pages, but the main issue is just around how the input box is rendered

How to return a result value from a async function in nodejs with MYSQL

I have created an AuthController.js file for handling MYSQL DB Query operation. For example, I’m taking one example i.e I created one fucntion in AuthController.js file for checking if particular email is exist or not in database and return a data value from it, here is my code:-

export const IsEmailExistRepo = async (email) => {
       const selectEmailQuery = 'SELECT email FROM users WHERE email=?'
       cosnt QueryResult = await db_connect().query(selectEmailQuery, [email], (err, data) => {
            if(err) throw err
            return data
       })
       return QueryResult
}

db_connect() is just a connection object of MYSQL connection instance. So, I want if an email is found then the function IsEmailExistRepo() will return data(which is an email) but in current senario it’s not happening, instead of returning data it returns a MYSQL connection object functions and events list.

I also use a callback for this and it’s completely working fine but I don’t want to do with callback because it creates a problem in AuthServices.js file where I put all my business logic for this for handling custom error for an API.

export const IsEmailExistRepo = (email, callback) => {
       const selectEmailQuery = 'SELECT email FROM users WHERE email=?'
       cosnt QueryResult = db_connect().query(selectEmailQuery, [email], (err, data) => {
            if(err) callback(err,null)
            callback(null, data)
       })
       return QueryResult
}

So I want to return a data result using async/await, I even tried using local variable and then return from the function after storing it but its also not working(due to await may be). Hwo can I do that?