Firestore query data based on string name

I am trying to query data in FB/FS.

Lets say I have data like this:

"items": {
    "id1":{
        "phrase": "the cat got hit by a van"
    }
    "id2":{
        "phrase": "the frog got hit by a bad driver"
    }
    "id3":{
        "phrase": "the dog got hit by a car"
    }
    "id4":{
        "phrase": "the deer got hit by a bus"
    }
}

If I wanted to query data where phrase contains “cat” or “dog || van“, how would I do this? Or can it be done?

I tried

db.collection("items").where("phrase", "array-contains", urlParams.get('s')).get().then((querySnapshot) => { ... }

but phrase is not an array, its a string.

Invalid hook call along with TypeError when reading useState with web app

I’m currently trying to work with React Native, and have managed to use Expo to sucessfully launch a blank project with a managed workflow. I have successfully managed to create an Android virtual device and have my app run with no issues where. However, when starting the app on a browser (pressing “W” within the console with Expo Go), I see a blank screen and several errors within Chrome’s console. I am entirely new to react, and have some minor JavaScript, HTML and CSS experience. I have left the error logs and a few code snippets below.

App.js:

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  //console.log('The application is now running!');
  //console.log('I am trying to type out some stuff and see how it goes');
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app! Hello there</Text>
      <Text>I'm trying to type stuff out and see how well it'll work out</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#17bf44',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

package.json:

{
  "name": "testproject",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~49.0.11",
    "expo-status-bar": "~1.6.0",
    "react": "18.2.0",
    "react-native": "0.72.4"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

app.json:

{
  "expo": {
    "name": "TestProject",
    "slug": "TestProject",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#17bf44"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#17bf44"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    }
  }
}

I have tried to follow the instructions provided by React given within the error log, but I do not believe fixes 1 and 3 apply to me. I have checked my versions of react and react-dom, and they seem to match. Here is the error log returned from the Google console when running my app on the web.

Is there any more information I can provide? Any suggestions as to what I can try from here?

Adjusting Sliding Div Height to 100% for Full Background Coverage on Hover

I’m looking to adjust the height of a sliding div to occupy 100% of its container. This entails having the background image fully cover the div on hover. Could someone kindly guide me on how to achieve this?
Below is the current code I’m working with:
Here is a screenshot that shows how to remove the gap/or increase the height of the sliding div on hover.
enter image description here

      .collections {
  padding: 90px 0 0 0;
  background-color: #ffffff;
}

  .collections .heading-container h1 {
  font-size: 48px;
  line-height: 38px;
  color: #28326e;
  font-weight: 800;
  font-family: "Mulish", sans-serif;
  text-align: center;
  margin: 0;
  padding: 0 0 40px 0;
}

  .collections .slide-animation-wrapper #slide1 {
  background: url("https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-the-wonder-wood.jpg") no-repeat center center transparent;
}
  .collections .slide-animation-wrapper #slide2 {
  background: url("https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-the-wonder-window.jpg") no-repeat center center transparent;
}
  .collections .slide-animation-wrapper #slide3 {
  background: url("https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-the-wonder-star.jpg") no-repeat center center transparent;
}
  .collections .slide-animation-wrapper #slide4 {
  background: url("https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-the-wonder-choice.jpg") no-repeat center center transparent;
}
  .collections .slide-animation-wrapper #slide5 {
  background: url("https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-our-saver.jpg") no-repeat center center transparent;
}
  .collections .slide-animation-wrapper #slide6 {
  background: url("https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-price-beater-plus.jpg") no-repeat center center transparent;
}
  .collections .slide-animation-wrapper .slide-wrapper {
  background-size: cover !important;
  height: 430px;
  position: relative;
  margin: 0 0 10px 0;
}

  .collections .slide-animation-wrapper .slide-wrapper::before {
  display: block;
  mix-blend-mode: multiply;
  position: absolute;
  z-index: 2;
}
  .collections .slide-animation-wrapper .slide-wrapper::after {
  content: "";
  height: 100%;
  left: 0;
  opacity: 0;
  position: absolute;
  top: 0;
  transition: all 1s ease 0s;
  width: 100%;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text {
  bottom: 0px;
  padding: 10px 15px 10px 15px;
  position: absolute;
  transition: top 0.1s ease 0s;
  width: 100%;
  z-index: 2;
  background-color: #f0f0f0;
  border: 1px solid #f0f0f0;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text .slide-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text .slide-heading h4 {
  font-size: 24px;
  line-height: 38px;
  color: #28326e;
  font-weight: 800;
  font-family: "Mulish", sans-serif;
  margin: 0;
  padding: 10px 0;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text .slide-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.8s ease 0s;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text .slide-body .button-wrapper {
  margin-left: 5px;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text .slide-body P {
  font-size: 19px;
  line-height: 21px;
  color: #58585a;
  font-family: "Mulish", sans-serif;
  margin: 0;
}
  .collections .slide-animation-wrapper .slide-wrapper .slide-text img {
  transition: opacity 0.1s ease 0s;
  max-width: 100%;
}
  .collections .slide-animation-wrapper .slide-wrapper:hover::after {
  opacity: 1;
}
  .collections .slide-animation-wrapper .slide-wrapper:hover .slide-body {
  max-height: 960px;
  opacity: 1;
}
  .collections .slide-animation-wrapper .slide-wrapper:hover .slide-heading img {
  opacity: 0;
}
<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">


</head>

<body>



    <section class="collections">
        <div class="container">
            <div class="heading-container">
                <h1>Collections</h1>
            </div>
            <div class="row">
                <div class="col-md-6 col-lg-4 g-1">

                    <div class="slide-animation-wrapper">
                        <div class="slide-wrapper" id="slide1">
                            <div class="slide-text">
                                <div class="slide-heading">
                                    <h4>The Wonder Wood</h4>
                                    <img src="https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-arrow-right.png"
                                        alt="double-hung-arrow">
                                </div>
                                <div class="slide-body">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
                                        tempor
                                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
                                        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                                        consequat.
                                        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
                                        eu
                                        fugiat nulla pariatur.</p>

                                    <div class="button-wrapper my-4">
                                        <a href=""
                                            class="btn btn-primary btn-lg btn-blue-border-white-color btn-blue-border-white-color--lg">Learn
                                            More</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-md-6 col-lg-4 g-1">

                    <div class="slide-animation-wrapper">
                        <div class="slide-wrapper" id="slide2">
                            <div class="slide-text">
                                <div class="slide-heading">
                                    <h4>The Wonder Window</h4>
                                    <img src="https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-arrow-right.png"
                                        alt="double-hung-arrow">
                                </div>
                                <div class="slide-body">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
                                        tempor
                                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
                                        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                                        consequat.
                                        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
                                        eu
                                        fugiat nulla pariatur.</p>
                                    <div class="button-wrapper my-4">
                                        <a href=""
                                            class="btn btn-primary btn-lg btn-blue-border-white-color btn-blue-border-white-color--lg">Learn
                                            More</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-md-6 col-lg-4 g-1">

                    <div class="slide-animation-wrapper">
                        <div class="slide-wrapper" id="slide3">
                            <div class="slide-text">
                                <div class="slide-heading">
                                    <h4>The Wonder Star</h4>
                                    <img src="https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-arrow-right.png"
                                        alt="double-hung-arrow">
                                </div>
                                <div class="slide-body">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
                                        tempor
                                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
                                        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                                        consequat.
                                        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
                                        eu
                                        fugiat nulla pariatur.</p>
                                    <div class="button-wrapper my-4">
                                        <a href=""
                                            class="btn btn-primary btn-lg btn-blue-border-white-color btn-blue-border-white-color--lg">Learn
                                            More</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-md-6 col-lg-4 g-1">

                    <div class="slide-animation-wrapper">
                        <div class="slide-wrapper" id="slide4">
                            <div class="slide-text">
                                <div class="slide-heading">
                                    <h4>The Wonder Choice</h4>
                                    <img src="https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-arrow-right.png"
                                        alt="double-hung-arrow">
                                </div>
                                <div class="slide-body">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
                                        tempor
                                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
                                        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                                        consequat.
                                        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
                                        eu
                                        fugiat nulla pariatur.</p>
                                    <div class="button-wrapper my-4">
                                        <a href=""
                                            class="btn btn-primary btn-lg btn-blue-border-white-color btn-blue-border-white-color--lg">Learn
                                            More</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-md-6 col-lg-4 g-1">

                    <div class="slide-animation-wrapper">
                        <div class="slide-wrapper" id="slide5">
                            <div class="slide-text">
                                <div class="slide-heading">
                                    <h4>Our Saver</h4>
                                    <img src="https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-arrow-right.png"
                                        alt="double-hung-arrow">
                                </div>
                                <div class="slide-body">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
                                        tempor
                                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
                                        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                                        consequat.
                                        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
                                        eu
                                        fugiat nulla pariatur.</p>
                                    <div class="button-wrapper my-4">
                                        <a href=""
                                            class="btn btn-primary btn-lg btn-blue-border-white-color btn-blue-border-white-color--lg">Learn
                                            More</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="col-md-6 col-lg-4 g-1">

                    <div class="slide-animation-wrapper">
                        <div class="slide-wrapper" id="slide6">
                            <div class="slide-text">
                                <div class="slide-heading">
                                    <h4>Price Beater Plus</h4>
                                    <img src="https://media.cmsmax.com/d3xadgynuglafnjbqq2la/double-hung-arrow-right.png"
                                        alt="double-hung-arrow">
                                </div>
                                <div class="slide-body">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
                                        tempor
                                        incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
                                        nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                                        consequat.
                                        Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
                                        eu
                                        fugiat nulla pariatur.</p>
                                    <div class="button-wrapper my-4">
                                        <a href=""
                                            class="btn btn-primary btn-lg btn-blue-border-white-color btn-blue-border-white-color--lg">Learn
                                            More</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>


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




</body>

</html>

Image not updating on S3 bucket HTML page when requesting data from AWS API

I have 2 boxes on an html page. X and Y. The user enters numbers clicks calculate and a image is supposed to appear. The problem is when I click calculate the image never updates with a image with new data on the plot (basically the image is not being updated). When I print the Image URL: on the bottom of the html page the url changes to the right image but its not displayed on the html page. If i copy the url into another tab it displays the image that should be displayed on the html page.

This is my HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API Calculator</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
    <h1>API Calculator</h1>
    <form id="calculator-form">
        <label for="x">Enter value for x:</label>
        <input type="number" id="x" name="x" required>
        <br>
        <label for="y">Enter value for y:</label>
        <input type="number" id="y" name="y" required>
        <br>
        <button type="submit">Calculate</button>
    </form>
    <div id="result">
        <img id="result-image" src="https://s3.amazonaws.com/aerocastwx.com/image_requests/res_plot.png" alt="Result Image">

    </div>
    <div id="image-url">Image URL: </div>
    <script src="app.js"></script>
</body>
</html>

Javascript code:

$(document).ready(function () {
    const form = $('#calculator-form');
    const resultDiv = $('#result');
    const resultImage = $('#result-image');

    form.on('submit', function (e) {
        e.preventDefault();

        const x = $('#x').val();
        const y = $('#y').val();

        // Replace {} placeholders in the API URL with actual values
        const apiUrl = `https://xxx.execute-api.us-east-1.amazonaws.com/september12stage/calculator?x=${x}&y=${y}`;

        $.ajax({
            url: apiUrl,
            method: 'GET',
            dataType: 'json',
            success: function (data) {
            console.log(data); // Check the response in the browser console
        
            if (data && data.ans !== undefined) {
                // Set the src attribute of the <img> element to display the image
                var resultImage = $('#result-image');
                resultImage.attr('src', data.ans); // Use data.ans as the image URL
                resultImage.show(); // Show the image
        
                // Update the Image URL div
                $('#image-url').text('Image URL: ' + data.ans);
            } else {
                console.error('Invalid API response:', data);
                resultDiv.html('Invalid API response');
                resultImage.hide(); // Hide the image container
            }
        },
            error: function (xhr, status, error) {
                console.error('Error fetching data from the API:', error);
                resultDiv.html('Error fetching data from the API');
                resultImage.hide(); // Hide the image container in case of an error
            }
        });
    });
});

React Redux how await dispatch ( typescript )

I have two components List and Modal to change items.
I also have two reducers that are responsible for the logic. Here’s what they look like:
my-project-list reducer
project-modal reducer

I am using the following action to send the data
edit project action
usage edit project action

When I send data for editing, I’d like to wait for a response, and if it’s successful, change the element in “my-projects-list” reducer.But I wouldn’t want to do this all the time since I can open this mode from another location and I don’t need to update the list all the time.

hello guys i want to delete the metadata from this extension, how can i do it? [closed]

I’ve got a little issue, and I could really use your help. I’m trying to get rid of some extra stuff called metadata from a certain extension, but I’m having some trouble doing it on my own. Metadata, in this case, is like extra information that comes with the extension, like who made it, its history, and other things like that.

I’ve been trying to do this by myself, but it’s not going so well. So, I thought I’d ask you all for some advice and assistance. Your know-how and ideas might be just what I need to figure this out.

To sum it up, I’m hoping you can share your knowledge and tips on this topic. Your help would mean a lot and could really make a difference in my quest to remove that metadata from this extension. Thanks a bunch in advance for your support!

REASON : it’s actually due to the unfortunate passing of our developer, which has left us without access to our application

here : (https://i.stack.imgur.com/2nPsF.png)

Add an element after Alpine.js element

I have a datepicker with tailwindcss and alpinejs and it works as expected:

this is my index.html file:

<!doctype html>
<html lang="en">
<head>
    <title>Datepicker</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
    <style>
        [x-cloak] {display: none !important;}
    </style>
</head>
<body class="flex justify-center">
<div class="flex flex-col my-10 space-y-5">
    <button onclick="addToFirstDiv()" class="text-white bg-red-800 p-1 rounded w-64">add to div#first</button>
    <button onclick="addToSecondDiv()" class="text-white bg-red-800 p-1 rounded w-64">add to div#second</button>

    <div id="first">
        <!-- datepicker -->
        <div x-data="datepicker()" x-init="[initDate(), initDatepicker()]" x-cloak>
            <div class="w-64 rounded-lg ring-1 ring-gray-100 shadow-lg">
                <div class="px-3 py-2">
                    <!-- header -->
                    <div class="flex justify-between items-center mb-2">
                        <div class="text-sm font-bold text-gray-800">
                            <span x-text="MONTH_NAMES[month]"></span>
                            <span x-text="year"></span>
                        </div>
                        <div class="text-gray-500 space-x-1">
                            <button type="button" class="transition ease-in-out duration-100 inline-flex p-1 rounded" :class="month === currentMonth && year === currentYear ? 'opacity-25' : 'hover:bg-gray-100'" :disabled="month === currentMonth && year === currentYear" @click="previousMonth()">
                                <svg class="h-4 w-4 inline-flex"  fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
                                </svg>
                            </button>
                            <button type="button" class="transition ease-in-out duration-100 inline-flex hover:bg-gray-100 p-1 rounded" @click="nextMonth()">
                                <svg class="h-4 w-4 inline-flex"  fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
                                </svg>
                            </button>
                        </div>
                    </div>

                    <div class="grid grid-cols-7 text-center -mx-1.5 text-gray-500 mb-2" style="font-size: 10px">
                        <!-- days of week -->
                        <span>M</span>
                        <span>T</span>
                        <span>W</span>
                        <span>T</span>
                        <span>F</span>
                        <span>S</span>
                        <span>S</span>
                    </div>

                    <div class="grid grid-cols-7 text-center mb-3 -mx-1.5">
                        <template x-for="blankDay in blankDays">
                            <span class="w-6 h-6 mb-1"></span>
                        </template>
                        <template x-for="(date, dateIndex) in daysOfMonth" :key="dateIndex">
                            <span x-text="date" @click="getDateValue(date)" class="w-6 h-6 mx-auto mb-1 flex justify-center items-center text-xs rounded-full" :class="[isPassedDay(date) ? 'opacity-25' : 'cursor-pointer transition ease-in-out duration-100 hover:bg-gray-100', isToday(date) ? 'text-red-800 font-bold' : 'text-gray-700']"></span>
                        </template>
                    </div>

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

    </div>

    <div id="second">

    </div>

    <script src="script.js"></script>
    <script>
        function addToFirstDiv() {
            document.getElementById('first').innerHTML += `<span>added-to-first-div</span>`;
        }

        function addToSecondDiv() {
            document.getElementById('second').innerHTML += `<span>added-to-second-div</span>`;
        }
    </script>
</div>
</body>
</html>

and this is my script.js:

const MONTH_NAMES = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

function datepicker() {
    return {
        timestampOfToday: null,
        currentMonth: null,
        currentYear: null,
        month: null,
        year: null,
        daysOfMonth: [],
        blankDays: [],

        initDate() {
            const today = new Date();
            this.currentMonth = today.getMonth();
            this.currentYear = today.getFullYear();
            this.month = this.currentMonth;
            this.year = this.currentYear;
            this.timestampOfToday = new Date(this.year, this.month, today.getDate()) / 1000;
        },

        isToday(date) {
            const today = new Date();
            const d = new Date(this.year, this.month, date);

            return today.toDateString() === d.toDateString();
        },

        isPassedDay(date)
        {
            const timestampOfDate = new Date(this.year, this.month, date) / 1000;
            return timestampOfDate < this.timestampOfToday;
        },

        getDateValue(date) {
            if (this.isPassedDay(date)) {return;}
            let selectedDate = new Date(this.year, this.month, date);

            selectedDate = `${selectedDate.getFullYear()}-${selectedDate.getMonth() + 1}-${selectedDate.getDate()}`;

            console.log(selectedDate)
        },

        initDatepicker() {
            let daysInMonth = new Date(this.year, this.month + 1, 0).getDate();
            let firstDayOfWeek = new Date(this.year, this.month).getDay(); // find where to start calendar day of week
            let blankDaysArray = [];
            let daysOfMonthArray = [];

            if (firstDayOfWeek === 0) {
                firstDayOfWeek = 7;
            }

            for ( let i = 2; i <= firstDayOfWeek; i++) {
                blankDaysArray.push(i);
            }

            for ( let i = 1; i <= daysInMonth; i++) {
                daysOfMonthArray.push(i);
            }

            this.blankDays = blankDaysArray;
            this.daysOfMonth = daysOfMonthArray;
        },

        previousMonth() {
            if (this.month === this.currentMonth && this.year === this.currentYear) {return;}
            if (this.month  === 0) {
                this.year--;
                this.month = 11;
            } else {
                this.month--;
            }
            this.initDatepicker();
        },

        nextMonth() {
            if (this.month === 11) {
                this.year++;
                this.month = 0;
            } else {
                this.month++;
            }
            this.initDatepicker();
        }
    }
}

my problem is when I click on first button to add an element after Alpine element, it’ll cause several errors and datepicker loses its functionality.

Why is this happening and how can I fix this?

Thank you very much for your help.

My useContext “isLoggedIn” variable is not updating after I navigate to another page after setIsLoggedIn(true)

I have a react context variable called “isLoggedIn” in a file called ‘AuthContext.js’, which I wrap my App.js with. This isLoggedIn variable tracks if a user is logged in to dynamically render a navigation bar and various pages. Here is my AuthContext.js file and my App.js which is wrapped with AuthProvider:

import { createContext, useContext, useState, useEffect } from 'react';
import axios from 'axios';

const AuthContext = createContext();

export const AuthProvider = ({ children }) => {
  const [isLoggedIn, setIsLoggedIn] = useState(false);

  // You can use useEffect to check the user's session 
  useEffect(() => {
    // Send a request to the /update1 
    //In summary, sending an empty request body with an empty Create1Dto object to
    // your /update1 endpoint should not cause any changes to the existing data in the user's profile.
    axios.get('http://localhost:8080/auth/isloggedin', {}, { withCredentials: true })
      .then(response => {
        if (response.status === 200) {
          // Profile updated successfully, user is logged in
          setIsLoggedIn(true);
        } else {
          // Handle other response statuses
          setIsLoggedIn(false);
        }
      })
      .catch(error => {
        if (error.response && error.response.status === 400 && error.response.data === 'User not found') {
          // User is not logged in or not authorized
          setIsLoggedIn(false);
        } else {
          // Handle other errors
          setIsLoggedIn(false);
        }
      });
  }, [isLoggedIn]);

  return (
    <AuthContext.Provider value={{ isLoggedIn, setIsLoggedIn }}>
      {children}
    </AuthContext.Provider>
  );
};

export const useAuth = () => {
  return useContext(AuthContext);
};

and I wrapped my app with AuthProvider:


import React from 'react';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'
import MyProfile from './MyProfile';
import { Box } from '@mui/material';
import ProfileCreation from './ProfileCreation'; 
import styled from '@emotion/styled';
import MainPage from './MainPage';
import QuizPage from './QuizPage';
import '../App.css'
import { useLocation } from 'react-router-dom';
import { AnimatePresence} from 'framer-motion';
import ResultsQuiz from './ResultsQuiz';
import LoginPage from './LoginPage';
import {useSelector} from 'react-redux';
import Create1 from './Create1';
import Create2 from './Create2';
import Create3 from './Create3';
import { AuthProvider } from '../components/AuthContext';
import { ProfileProvider } from '../components/ProfileContext';
import { ImageUploadProvider } from '../components/ImageUploadContext';
import LogoutPage from './LogoutPage';
import MyPersonalProfile from './MyPersonalProfile';

function AppContent() {
    const location = useLocation();

    const { isAuthenticated, user } = useSelector(state => state.auth);

   //Use the isAuthenticated state to conditionally render components based on the user's authentication status.


    const MainContainer = styled(Box)({
        minWidth: '80rem', // or your desired value
        minHeight: '45rem', // or your desired value
        overflow: 'auto'
      });
      
      const questions = [
        { id: 1, text: "I am the life of the party." },
        { id: 2, text: "I feel little concern for others." },
        { id: 3, text: "I am always prepared." },
        { id: 4, text: "I get stressed out easily." },
        { id: 5, text: "I have a rich vocabulary." },
        { id: 6, text: "I don't talk a lot." },
        { id: 7, text: "I am interested in people." },
        { id: 8, text: "I leave my belongings around." },
        { id: 9, text: "I am relaxed most of the time." },
        { id: 10, text: "I have difficulty understanding abstract ideas." },
        { id: 11, text: "I feel comfortable around people." },
        { id: 12, text: "I insult people." },
        { id: 13, text: "I pay attention to details." },
        { id: 14, text: "I worry about things." },
        { id: 15, text: "I have a vivid imagination." },
        { id: 16, text: "I keep in the background." },
        { id: 17, text: "I sympathize with others' feelings." },
        { id: 18, text: "I make a mess of things." },
        { id: 19, text: "I seldom feel blue." },
        { id: 20, text: "I am not interested in abstract ideas." },
        { id: 21, text: "I start conversations." },
        { id: 22, text: "I am not interested in other people's problems." },
        { id: 23, text: "I get chores done right away." },
        { id: 24, text: "I am easily disturbed." },
        { id: 25, text: "I have excellent ideas." },
        { id: 26, text: "I have little to say." },
        { id: 27, text: "I have a soft heart." },
        { id: 28, text: "I often forget to put things back in their proper place." },
        { id: 29, text: "I get upset easily." },
        { id: 30, text: "I do not have a good imagination." },
        { id: 31, text: "I talk to a lot of different people at parties." },
        { id: 32, text: "I am not really interested in others." },
        { id: 33, text: "I like order." },
        { id: 34, text: "I change my mood a lot." },
        { id: 35, text: "I am quick to understand things." },
        { id: 36, text: "I don't like to draw attention to myself." },
        { id: 37, text: "I take time out for others." },
        { id: 38, text: "I shirk my duties." },
        { id: 39, text: "I have frequent mood swings." },
        { id: 40, text: "I use difficult words." },
        { id: 41, text: "I don't mind being the center of attention." },
        { id: 42, text: "I feel others' emotions." },
        { id: 43, text: "I follow a schedule." },
        { id: 44, text: "I get irritated easily." },
        { id: 45, text: "I spend time reflecting on things." },
        { id: 46, text: "I am quiet around strangers." },
        { id: 47, text: "I make people feel at ease." },
        { id: 48, text: "I am exacting in my work." },
        { id: 49, text: "I often feel blue." },
        { id: 50, text: "I am full of ideas." }
    ];
    

    return (
    <AnimatePresence>
      <MainContainer>
      <AuthProvider>
        <ProfileProvider>
            <Routes location={location} key={location.pathname}>
              <Route path="/myprofile" element={<MyPersonalProfile />} />
              <Route path="/" element={<MainPage />} />
              <Route path="/create" element={<ProfileCreation />} />
              <Route path = "/create/1" element ={<Create1 />} />
              <Route path = "/create/2" element ={<Create2 />} />
              <Route path = "/create/3" element ={<Create3 />} />
              <Route path="/quiz/:questionId" element={<QuizPage questions={questions}/> }  />
                <Route path="/resultsquiz" element={<ResultsQuiz />}/>
                <Route path="/login" element={<LoginPage />} />
                <Route path="/logout" element={<LogoutPage />} />
            </Routes>
            </ProfileProvider>
            </AuthProvider>
      </MainContainer>
      </AnimatePresence>
    );
  }
  

  export default AppContent;

In my LoginPage, which is a sibling component of MainPage in the react router, I update isLoggedIn to ‘true’ after successful login and then use ‘Navigate’ to navigate back to the main page. But when I am on the main page, when I console.log “isLoggedIn”, it shows up as false and the conditional rendering for the navbar is incorrect. I don’t understand why my isLoggedIn state from my context is not updating. Here is my code for LoginPage.js and my code for MainPage.js.


import * as React from 'react';
import Box from '@mui/material/Box';
import styled from '@emotion/styled';
import RightBox from '../components/RightBox.js';
import CreateNavbar from '../components/CreateNavbar.js';
import LeftBox from '../components/LeftBox.js'
import { Typography } from "@mui/material"; 
import InputField from '../components/InputFIeld.js';
import {motion} from 'framer-motion';
import { useTheme } from '@emotion/react';
import {Button} from '@mui/material';
import { useState } from 'react';
import SelectError from '../components/SelectError.js';
import { useEffect } from 'react';
import jwt_decode from 'jwt-decode';
import { login, logout } from '../redux/authSlice.js'
import { useSelector, useDispatch } from 'react-redux';
import Cookies from 'js-cookie';
import LoginForm from '../components/LoginForm.js';
import Stack from '@mui/material/Stack';
import LogButton from '../components/LogButton.js';
import axios from 'axios';
import { useAuth } from '../components/AuthContext.js';
import SelectSuccess from '../components/SelectSuccess.js';
import { Navigate, useNavigate } from 'react-router-dom';
import MainNavbar from '../components/MainNavbar.js';
import PasswordInputField from '../components/PasswordInputField.js';
import { useProfile } from '../components/ProfileContext.js';


const FullPageCenter = styled('div')({
  display: 'flex',
  justifyContent: 'center',
  alignItems: 'center',
  minHeight: '100vh', // Set the minimum height to 100% of the viewport height
});

//this is to center the content

const ItalicText = styled('div')(({ theme }) => ({
  fontFamily: theme.typography.h1.fontFamily,
  fontStyle: 'italic',
  fontSize: '8rem',
  color: theme.palette.accent.main,  // Accessing the accent.main color
  // other styles for your component
  lineHeight: '0.9',
}));


const Wrapper = styled('div')({
    justifyContent: 'center',
    alignItems: 'center',
    height: '45rem',
    width: '80rem',
    overflowX: 'hidden',
    overflowY: 'scroll',
    marginBottom: '4rem',
    position: 'relative', // This is important for the absolute positioning of the child.
});
//this is to prevent resizing....


//does putting position of top level copmonent as relative make all the child components, including grandchildren components, relative to the top level component? 

//this is relative position only deals with direct children that are absolutely positioned

//wrapper is outermost container...centers stuff in scree horizontall yand vefitcally
//overflowing content will be clipped
//relative means child elements will be positioned relative to wrapper
const CenterContainer = styled(Box)(({ theme }) => ({
    width: '98%',
    display: 'flex', //this ensures marginLeft: auto on right box pushes to right
    minHeight: '98%',
    height: '98%',
    margin: 'auto',
    marginTop: '4rem',
    overflowX: 'hidden',
    overflowY: 'hidden',
    //if there isnt enough space, parent container forces horizonal scroll
  }));

  //this is immediate child of wrapper, contains right box
  //relative makes container point of ref to absolutely positioned children
  //overflowX: 'scroll' and overflowY: 'scroll': These styles force both horizontal and vertical scrollbars to appear if the content inside CenterContainer exceeds its boundaries.
  


// you can add styling on top of navbar to position it!


export default function LoginPage({children}) {

    const [ token, setToken ] = useState('');

    const [ activeButton, setActiveButton ] = useState('LOGIN') //default to log in

    const { isAuthenticated, user } = useSelector(state => state.auth);
    //useSelector is reading variable from reducer
    //we want to take these variables from redux state

const theme = useTheme();

  const {isLoggedIn, setIsLoggedIn} = useAuth();
  const {isProfileCreated} = useProfile();

  const [ success, setSuccess ] = useState(false);

  const [error, setError ] = useState(false);

  const [taken, setTaken] = useState(false);
  

  const navigate = useNavigate();

  const handleLogin = async (inputUsername, inputPassword) => {
    try {
        const loginDto = {
          username: inputUsername,
          password: inputPassword,
          // Include other registration data fields here
        };

      
      const config = {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        },
        withCredentials: true,
      };
  
      const response = await axios.post('http://localhost:8080/auth/login', loginDto, config);
  
      if (response.status === 200) {
        // Successful login
        setIsLoggedIn(true);
        navigate('/');
        console.log('Login successful!');
      } else {
        // Handle login failure
        setIsLoggedIn(false);
        setError(true);
        console.error('Login failed.');
      }
    } catch (error) {
      // Handle other errors
      setIsLoggedIn(false);
      setError(true);
      console.error('Error during login:', error);
    }
  };

  //if spring security session management exists in java backend, dont need to make front end handle sessions
  

const handleSubmit = (event) => {
    event.preventDefault();

    const formData = new FormData(document.getElementById("submission"));  // Use event.currentTarget
    const inputUsername = formData.get("username");
    const inputPassword = formData.get("password");
    console.log("this is the formdata's username:" , inputUsername)
    console.log("formdata", Object.fromEntries(formData));



    if (activeButton === "LOGIN") {
        handleLogin(inputUsername, inputPassword);
    } else if (activeButton === "REGISTER") {
        handleRegister(inputUsername, inputPassword);
    }
};

const handleRegister = async (inputUsername, inputPassword) => {
  if (isLoggedIn === true ){
    console.log("Need to log out");
    return;
  }

  // Logic for registration
  try {
    const registrationDto = {
      username: inputUsername,
      password: inputPassword,
      // Include other registration data fields here
    };


    const config = {
      headers: {
        'Content-Type': 'application/json', // Set the request header to JSON
      },
    };

    const response = await axios.post('http://localhost:8080/auth/register', registrationDto, config);

    if (response.status === 200) {
      // Successful registration
      console.log('Registration successful!');
      setSuccess(true);
    } else {
      // Handle registration failure
      console.error('Registration failed.');
      setTaken(true);
    }
  } catch (error) {
    // Handle other errors
    console.error('Error during registration:', error);
  }
};


useEffect(() => { 

  console.log(isLoggedIn, "am i logged in");
  console.log(isProfileCreated, "do i have a profile created")
    
}, []);


  return (
    <motion.div
    initial={{opacity: 0}}
    animate={{opacity: 1}}
    exit={{opacity: 0, transition: {duration: 0.4}}}>
    <FullPageCenter>
    <Wrapper>
    <MainNavbar />
    {/* adding navbar above container so its rendered above containers... */}
    <CenterContainer>
      <LeftBox>
      { isLoggedIn===true &&
    <div sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100v' }}>
      <ItalicText style={{wordWrap:"break-word", overflowWrap: "break-word"}}>You are logged in!</ItalicText> 
      </div>
        }
        {
        (isLoggedIn !== true) &&
      <ItalicText style={{marginLeft: '6rem', wordWrap:"break-word", overflowWrap: "break-word", marginBottom: '5rem',marginTop: '0.7rem'}}>Log in to your account</ItalicText> 
        }
         
      </LeftBox>
        <RightBox justify="yes">
          {
            isLoggedIn!==true &&
            <Stack spacing="1rem" >
            <Box flexDirection="row" style={{ display: 'flex', width: '100%' }} justifyContent="space-between"> 
            {/* the space between is inside the parent stack */}
            <LogButton label="LOGIN" width='9rem' onClick={() => setActiveButton('LOGIN')} isActive={activeButton==='LOGIN'}/>
            <LogButton label="REGISTER" width='9rem' onClick={()=> setActiveButton('REGISTER')} isActive={activeButton==='REGISTER'}/>
            {/* i use isActive...boolean, if true then colors it blue */}
            </Box>
            {/* <Stack spacing="1rem"> don't need this stack */} 
            <form onSubmit={handleSubmit} id="submission">
            <InputField name="username" label="USERNAME" />
            <PasswordInputField name="password" label="PASSWORD" />
            <LogButton onClick={handleSubmit} label="submit" color="#000000" style={{flex:1}}/>
            </form>
             {/*the submit button fills the space in the flex component..the stack component   */}
            {/* </Stack> */}
            {/* <AuthContent />  */}
            
            </Stack>
}

{ isLoggedIn===true &&

<p>Time to go find your traitmate!</p>

}
            {error && 
            <SelectError message="Wrong login credentials. Try again?"></SelectError>
            }
            { 
            success &&
            <SelectSuccess message="Successfully registered! Now log in."></SelectSuccess>
}
{
  taken &&
  <SelectError message="The username is already taken! Try another"></SelectError>
}
        </RightBox>
    </CenterContainer>
    </Wrapper>
    </FullPageCenter>
    </motion.div>
  );
}

and MainPage.js:

import React from "react";
import MainHeader from "../components/MainHeader";
import Box from '@mui/material/Box';
import styled from '@emotion/styled';
import {motion} from 'framer-motion';
import MainNavbar from "../components/MainNavbar";
import { useAuth } from "../components/AuthContext";
import { useProfile } from "../components/ProfileContext";
import { useEffect } from "react";

const FullPageCenter = styled('div')({
    display: 'flex',
    justifyContent: 'center',
    alignItems: 'center',
    minHeight: '100vh', // Set the minimum height to 100% of the viewport height
    //position: 'relative', //ensure relative positioning for stacking context
    backgroundImage: 'url("/MOONASSI_16_UNTITLED.png")', // <-- add this line
    backgroundSize: '800px',  // cover ensures the image fills the container without stretching
    backgroundPosition: '17rem bottom',  // center the image
    backgroundRepeat: 'no-repeat',  // don't repeat the image
    position: 'relative',
  });
  
  
  const Wrapper = styled('div')({
      justifyContent: 'center',
      alignItems: 'center',
      height: '45rem',
      width: '100%',
      overflowX: 'scroll',
      overflowY: 'scroll',
      marginBottom: '4rem',
      position: 'relative',
      // This is important for the absolute positioning of the child.
      
  });
  //this is to prevent resizing....
  
  
  //does putting position of top level copmonent as relative make all the child components, including grandchildren components, relative to the top level component? 
  
  //this is relative position only deals with direct children that are absolutely positioned
  
  //wrapper is outermost container...centers stuff in scree horizontall yand vefitcally
  //overflowing content will be clipped
  //relative means child elements will be positioned relative to wrapper
  const CenterContainer = styled('div')(({ theme }) => ({
      width: '100%',
      display: 'flex', //this ensures marginLeft: auto on right box pushes to right
      minHeight: '98%',
      height: '98%',
      marginTop: '2rem',
      border: '1px solid black',
      //if there isnt enough space, parent container forces horizonal scroll
    }));


  
  

function MainPage() {

  const {isLoggedIn} = useAuth();
  const {isProfileCreated} = useProfile();
  useEffect(() => { 

    console.log(isLoggedIn, "am i logged in");
    console.log(isProfileCreated, "do i have a profile created")
      
  }, []);
  return (
    <motion.div
    initial={{opacity: 0}}
    animate={{opacity: 1}}
    exit={{opacity: 0, transition: {duration: 0.8}}}>
    <FullPageCenter sx={{zIndex: -1000}}>
    <Wrapper> 
     <CenterContainer> 
    <MainNavbar sx={{zIndex: 9999 }} />
    <MainHeader/> 
    </CenterContainer>
    </Wrapper> 
    </FullPageCenter> 
   </motion.div>
  );
}


export default MainPage;

My navbar is also not receiving the isLoggedIn state update and is incorrectly rendering:

import React from "react";
import { AppBar, Toolbar, CssBaseline, Typography } from "@mui/material";
import { Link } from "react-router-dom";
import styled from "@emotion/styled";
import { useAuth } from "./AuthContext";
import { useProfile } from "./ProfileContext";
import { BrowserRouter as Router } from 'react-router-dom';
import { useEffect } from "react";

const NavbarWrapper = styled('div')({
  width: '100vw',//adding this centers the navbar
  height: '4rem', // Set the height to 4rem 
  // Add any other styling you need for the navbar
  position: 'fixed',
  overflow: 'visible',
  zIndex: '1000',
  pointerEvents: 'auto', //set this to high value to make text hoverable in MyProfile.js
  // i think this overflow auto is what causes it to be fixed size
});

const NavbarAppBar = styled(AppBar)`
  background-color: transparent;
`;

const NavbarToolbar = styled(Toolbar)`
  display: flex;
  justify-content: center;
  align-items: center;
`;


const NavbarNavlinks = styled.div`
display: flex;
align-items: center;
flex: 1;
justify-content: space-between; /* Spread items evenly */
align-items: center;
margin: 10rem 10rem;
gap: 9rem;
pointer-events: 'auto';
`;

const NavbarLink = styled(Link)(({ theme }) => ({
  fontFamily: theme.typography.body2.fontFamily,
  fontWeight: 300,
  pointerEvents: 'auto',
  textDecoration: 'none',
  zIndex: 9999,
  color: 'black',
  '&:hover': {
      color: 'blue',
      borderBottom: '1px solid blue'
  }
}));

function MainNavbar() {
  const {isLoggedIn} = useAuth();
  const {isProfileCreated} =useProfile();

 useEffect(() => {

console.log(isLoggedIn, "am i logged in from navbar?");
 }
  , []);

  useEffect(() => {
    console.log('MainNavbar re-rendered with isLoggedIn value:', isLoggedIn);
});


 

  // in styled, for font weight, remove the brackets
  
  return (
    <NavbarWrapper>
    <NavbarAppBar position="static" elevation={0} sx={{background: '#dfd3bc', maxHeight:'4rem',}}>
      {/* the sx prop has a higher specificity...easier to override styles */}
      <CssBaseline/>
      <NavbarToolbar>
      { (isLoggedIn===false || isLoggedIn===null) &&
        <NavbarNavlinks>
          <NavbarLink to="/login"><b>LOG IN</b></NavbarLink>
          <NavbarLink to="/"> <b>MAIN</b></NavbarLink>
          <a href="http://jasminenoodlewavey.vercel.app" style={{ textDecoration: 'none', color: 'black'}}>ABOUT THE CREATOR</a>
        </NavbarNavlinks>
        }
        { isLoggedIn===true && isProfileCreated===false &&
        <NavbarNavlinks>
          <NavbarLink to="/logout"><b>LOG OUT</b></NavbarLink>
          <NavbarLink to="/create/1"> <b>CREATE PROFILE</b></NavbarLink>
          <a href="http://jasminenoodlewavey.vercel.app" style={{ textDecoration: 'none', color: 'black'}}>ABOUT THE CREATOR</a>
        </NavbarNavlinks>
        }
        { isLoggedIn===true && isProfileCreated===true &&
        <NavbarNavlinks>
          <NavbarLink to="/logout"><b>LOG OUT</b></NavbarLink>
          <NavbarLink to="/myprofile"> <b>MY PROFILE</b></NavbarLink>
          <NavbarLink to="/match"> <b>FIND YOUR MATCH</b></NavbarLink>
          <a href="http://jasminenoodlewavey.vercel.app" style={{ textDecoration: 'none', color: 'black'}}>ABOUT THE CREATOR</a>
        </NavbarNavlinks>
        }
      </NavbarToolbar>
    </NavbarAppBar>
    </NavbarWrapper>
  );
}

export default MainNavbar;


Is this an issue with my use of Navigation? Does my redirect from LoginPage.js to MainPage.js reset the useContext value? I’m unsure about how to proceed since I think I’ve implemented my AuthContext correctly….

why does map() display my items in a column vs a row?

I’m trying to create react movie app for my hw and I’m following a tutorial.(https://www.youtube.com/watch?v=jc9_Bqzy2YQ) I’m trying to make the movie display in a row so that I can scroll through them.

return (
    <div className='container movie-app'>
      <div className='row'>
        <div class="col-sm">
          <MovieList movies={movies} />
        </div>
          
      </div>
        
    </div>
  );
}
function MovieList(props) {
  return (
    <div>
        {props.movies.map((movie,index) => (<div>
            <img src={movie.Poster}  alt="movie"></img>
        </div>) )}
    </div>
  )
}

I’m getting an error code of

react-jsx-dev-runtime.development.js:79 Warning: Each child in a list should have a unique "key" prop.

I tried to fix the key error by assigning it key={imdbID} in movielist.js but that did nothing. I tried changing the classes of the divs to see if that would help but that also did nothing.

Discord.js code works fine while playing local files, while trying to play urls it doesn’t play anything



const Discord = require('discord.js');

const { Client, GatewayIntentBits } = require('discord.js');

const client = new Client({ intents:

  [

      GatewayIntentBits.Guilds,

      GatewayIntentBits.GuildMessages,

      GatewayIntentBits.GuildVoiceStates,

]

});

const config =  require('./config.json');

const { joinVoiceChannel, createAudioPlayer, NoSubscriberBehavior, createAudioResource, AudioPlayerStatus, VoiceConnectionStatus, StreamType } = require('@discordjs/voice');

const { join } = require('path');

client.once('ready', async() => {

    console.log("connected");

    const channels = client.guilds.cache.find(f => f.name==="<my-guild>").channels;

  let channel= channels.cache.find(r => r.name === "General");

const connection = joinVoiceChannel({

channelId: channel.id,

guildId: channel.guildId,

adapterCreator: channel.guild.voiceAdapterCreator,

});                                                                                                                                         console.log("joined voice channel");

const player = createAudioPlayer();

let resource = createAudioResource("https://streams.ilovemusic.de/iloveradio2.mp3", { inlineVolume: true,

  inputType: StreamType.Arbitrary});

resource.volume.setVolume(1)

connection.subscribe(player);

player.play(resource);

});

client.login(config.token);

It worked fine last month, Trying to run it this month and nothing is heard via stream, but local audio files work fine.

Expectation: Url should play as discord createAudioResource supports urls.

The main problem is local files play, while remote urls don’t. There’s no error though so I am confused on how to debug it.

How can I deploy Typescript express server in Cpanel?

I have dist and src folder in my root. Src folder contain typescript file. I can try many way to deploy. I got in browser:

"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"dev": "ts-node-dev --respawn --transpile-only ./src/server.ts",
"start": "node dist/server.js",
"build": "tsc",
"lint:check": "eslint --ignore-path .eslintignore --ext .js,.ts .",
"lint:fix": "lint . --fix",
"prettier:check": "prettier --ignore-path .gitignore --write "**/*.+(js|ts|json)"",
"prettier:fix": "prettier --write .",
"lint-prettier": "yarn lint:check && yarn prettier:check"

}

503
Service Unavailable
The server is temporarily busy, try again later!

My code folder structure

How can solve this issue and deploy?

Non-recursive traverse and Element implicitly has an ‘any’ type

I’m trying to rewrite this tiny function to TypeScript. Accessing entry[key] throws following ts error:

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'StringObjectOrArray'.
   No index signature with a parameter of type 'string' was found on type 'StringObjectOrArray'.ts(7053)

It doesn’t make sense to me. for .. in returns string index even on arrays which was new to me, but obviously integer as string can be natively used as array index. What am I missing?

type StringKeyObject = { [key: string]: unknown };
type StringObjectOrArray = StringKeyObject | StringKeyObject[];

function traverse(obj: StringObjectOrArray) {
  if (!obj) {
    return;
  }

  const stack: [string, StringObjectOrArray][] = [['root', obj]];
  while (stack.length) {
    const [path, entry] = stack[0];
    for (const key in entry) {
      if (entry[key] && typeof entry[key] === "object") { // ts error here
        stack.push([`${path}.${key}`, entry[key]]);
      } else {
        console.log("%s: %s", `${path}.${key}`, entry[key]);
      }
    }
    stack.shift();
  }
}

Bellow is working JavaScript code:

function traverse(obj) {
  if (!obj) {
    return;
  }

  const stack = [['root', obj]];
  while (stack.length) {
    const [path, entry] = stack[0];
    for (const key in entry) {
      if (entry[key] && typeof entry[key] === "object") {
        stack.push([`${path}.${key}`, entry[key]]);
      } else {
        console.log("%s: %s", `${path}.${key}`, entry[key]);
      }
    }
    stack.shift();
  }
}

traverse({
    one: "hello",
    two: "world",
    three: {
        one: 1,
        two: 2,
        three: 4,
        four: [{
            one: true,
            two: false
        }]
    },
    four: "!"
});

Unable to see the “Do Not Track” (DNT) header in the fetch request

I need to make a request to an API, and when I include the “Do Not Track” (DNT) header in the request, I am able to successfully send the request via Postman and view the desired set-cookie responses.
Postman Request

It is quite interesting that when I try to send the same request in a browser, I cannot see the DNT option in the headers. However, if I replace DNT with any other header, I am able to see it in the request headers. Unfortunately, the header that is useful for my purpose is DNT. Does anyone know the reason behind this?

The code block that I used to make the request:

  createOCAPISession() {
    return fetch(this.OCAPISessionsURL, {
      method: 'POST',
      headers: {
        Authorization: 'Bearer ' + this.get('access_token'),
        DNT: '0',
        Testheader: 'test'
      }
    });
  }

Below, you can see the request I sent via the browser. As you can see, even though the Testheader is visible in the request headers, we cannot see the DNT header in the headers, and the response we receive is different from what we see in Postman.

The HTTP Request headers for the request that is sent from the Browser:

The HTTP Request headers for the request that is sent from the Browser

The HTTP Response headers for the request that is sent from the Browser:

The HTTP Response headers for the request that is sent from the Browser

Furthermore, I have tested it on different browsers and in incognito mode, yet there is no change. What could be the underlying issue, in your opinion?

Thank you in advance.

I am getting problem when using tailwind with react

This is my react code i want to use tailwind propeties here i already install tailwind during installing of react font-bold property work other propeties doesn’t work like text-xl **HERE IS MY CODE **

`
import React from ‘react’

const page = () => {

return (

<>

<div className='text-xl font-bold'>Ikram khan</div>

</>

)

}

export default page`

Toggle NavBar in React

I want to make a navbar for my site and I am doing it using React for the first time now. I have done this with vanilla JS and I am stuck on how to toggle it.

const navBtn = document.querySelector("#menu");
const menuBar = document.querySelector("[role='menuBar']");

navBtn.addEventListener("click", () => {
  const isExpanded = JSON.parse(navBtn.getAttribute('aria-expanded')); // we are storing the value if btn has value of expanded or not... then we just reverse it below
  navBtn.setAttribute('aria-expanded',!isExpanded); // if true then set it to false and vice verse
  menuBar.classList.toggle('hidden');
  menuBar.classList.toggle('flex');
});

This is the code I used earlier. I get the toggle button as navBtn and the link section as menuBar and use aria-expanded as an indicator whether the bar is expanded or not.
But now I am stuck on how to achieve this same code in react.
I am using Tailwind CSS for designing