Do I still use local host once I deploy my react native app?

I am currently building the backend for my react-native app, and I was wondering:

I have the app.listen(“insert port”). This works fine, but when I want to deploy to lets say, the app store, do I need to change it? I mean, does my app have to keep loading on my local host? Or do I use some other port.

Thank you.

get an answer on the currently active breakpoint?

I am using MUI.

I want to know the currently used breakpoint, is it xs, sm, md,lg and so on.

does MUI provide a method for doing so?

maybe by doing:

import { useTheme } from '@mui/material'
const Component = () => {
  const theme = useTheme()
  console.log(theme.breakpoints.currentActiveBreakpoint) // lg
}

or maybe by doing:

import { useTheme } from '@mui/material'
const Component = () => {
  const theme = useTheme()
  console.log(theme.breakpoints.is('lg')) // true
}

Why?

I have a created component which takes a prop called oriantation, and I want to consume it like this:

<TabsPanelsLayout tabs={tabsList} oriantation={theme.breakpoints.isBetweenAndIncluding('xs', 'md') ? 'vertical' : 'horizintal'} />

which is important to render something either like this:

enter image description here

or like this:

enter image description here

How to filter items from an array?

I made an ecommerce website and I’m trying to filter all the items by category, but I’m not able to make it work because I load my products with json/fetch (I tried the same code without using json/fetch and it works fine).

I have all my products in an array, and each product has a category (“snacks”, “candy” or “drink”), all the info for each product is in the json(category, name, id, etc). I have filter buttons for each category with it’s corresponding id.

I don’t get any error, it simply does not work. Here’s the relevant code:

//FILTER BUTTONS

<div class="filter-btns">
     <button class="pb-3 filter-btn" id="all">All</button>
     <button class="pb-3 filter-btn" id="drinks">Drinks</button>
     <button class="pb-3 filter-btn" id="snacks">Snacks</button>
     <button class="filter-btn" id="candy">Candy</button>
</div>
// LOAD PRODUCTS WITH FETCH

const URL = "products.json"
const products = []

const showProducts = (products) =>
{
    let container = document.querySelector('#container');
    for (const product of products)
    {   
        let item = `<div class="filter-item all ${product.category}" id="${product.id}">
                        <div class="card h-100 shadow">
                            <img id="${product.id}" class="card-img-top" src="${product.img}" alt="..."/>
                            <div class="card-body p-4">
                                <div class="text-center">
                                    <h5>"${product.name}"</h5>
                                    <div class="d-flex justify-content-center small text-warning mb-2">
                                        <div class="bi-star-fill"></div>
                                    </div>
                                    <span class="text-muted text-decoration-line-through"></span>
                                    "${product.price}"
                                </div>
                             </div>
                            <div class="card-footer p-4 pt-0 border-top-0 bg-transparent">
                                <div class="text-center"><a class="cartButton btn btn-outline-dark mt-auto" id="${product.id}" href="#">Add to cart</a></div>
                             </div>
                        </div>
                    </div>`;
        container.innerHTML += item
    }
}

const getData = async () =>
{
    try
    {
        const response = await fetch(URL);
        const data = await response.json();
        products.push(...data);
        showProducts(data);
    }
    catch(e)
    {
        console.log(e);
    }
}

getData();
// FILTER ITEMS

const allFilterItems = document.querySelectorAll('.filter-item');
const allFilterBtns = document.querySelectorAll('.filter-btn');

allFilterBtns.forEach((btn) => {
  btn.addEventListener('click', () => {
    showFilteredContent(btn);
  });
});

function showFilteredContent(btn){
  allFilterItems.forEach((item) => {
    if(item.classList.contains(btn.id)){
      item.style.display ="block";
    }
    else {
      item.style.display = "none";
    }
  });
}

Any help would be amazing. Thanks!

Client is missing “GuildVoiceStates” intent error while making a discord bot from a tutorial on v14

I was using a tutorial on youtube to make a music Discord bot with javascript and I run into this problems with the guilds, i have already changed them for the new guild-names as seen on the source code, but it did not seem to work although I am using discord.js v14

This is the error message
PS C:UsersmatiaDesktopbot_de_discord> node index.js

    C:UsersmatiaDesktopbot_de_discordnode_modulesdiscord-playerdistPlayer.js:51
                throw new PlayerError_1.PlayerError('client is missing "GuildVoiceStates" intent');
                ^
    
    PlayerError: [PlayerError] client is missing "GuildVoiceStates" intent
        at new PlayerError (C:UsersmatiaDesktopbot_de_discordnode_modulesdiscord-playerdistStructuresPlayerError.js:28:15) 
        at new Player (C:UsersmatiaDesktopbot_de_discordnode_modulesdiscord-playerdistPlayer.js:51:19)
        at Object.<anonymous> (C:UsersmatiaDesktopbot_de_discordindex.js:28:17)
        at Module._compile (node:internal/modules/cjs/loader:1155:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
        at Module.load (node:internal/modules/cjs/loader:1033:32)
        at Function.Module._load (node:internal/modules/cjs/loader:868:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
        at node:internal/main/run_main_module:22:47 {
      createdAt: 2022-10-22T20:46:33.101Z,
      statusCode: 'PlayerError'
    }

And this is the source code

const Discord = require("discord.js")
const dotenv = require("dotenv")
const { REST } = require("@discordjs/rest")
const { Routes } = require("discord-api-types/v9")
const fs = require("fs")
const { Player } = require("discord-player")

dotenv.config()
const TOKEN = process.env.TOKEN

const LOAD_SLASH = process.argv[2] == "load"

const CLIENT_ID = "1033422580654280774"
const GUILD_ID = "699272174736900117"



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

const client = new Discord.Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
  ]
})

client.slashcommands = new Discord.Collection()
client.player = new Player(client, {
    ytdlOptions: {
        quality: "highestaudio",
        highWaterMark: 1 << 25
    }
})

let commands = []

const slashFiles = fs.readdirSync("./slash").filter(file => file.endsWith(".js"))
for (const file of slashFiles){
    const slashcmd = require(`./slash/${file}`)
    client.slashcommands.set(slashcmd.data.name, slashcmd)
    if (LOAD_SLASH) commands.push(slashcmd.data.toJSON())
}

if (LOAD_SLASH) {
    const rest = new REST({ version: "9" }).setToken(TOKEN)
    console.log("Deploying slash commands")
    rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), {body: commands})
    .then(() => {
        console.log("Successfully loaded")
        process.exit(0)
    })
    .catch((err) => {
        if (err){
            console.log(err)
            process.exit(1)
        }
    })
}
else {
    client.on("ready", () => {
        console.log(`Logged in as ${client.user.tag}`)
    })
    client.on("interactionCreate", (interaction) => {
        async function handleCommand() {
            if (!interaction.isCommand()) return

            const slashcmd = client.slashcommands.get(interaction.commandName)
            if (!slashcmd) interaction.reply("Not a valid slash command")

            await interaction.deferReply()
            await slashcmd.run({ client, interaction })
        }
        handleCommand()
    })
    client.login(TOKEN)
}

Angular http get returning undefined

I tried to find an answer here but couldn´t. I´m new to Angular and I made a service for consulting an API, I checked on postman and the request and headers are valid, but my code is compiling and returning the following error on browser:

ERROR TypeError: Cannot read properties of undefined (reading 'get')

My code:

 http:HttpClient;

  constructor() { 

    console.log("creates here");

  }

  getCurrencySymbolList() {

    console.log("gets here");
    console.log(`${this.apiUrl}${this.apiSymbols}`);

    this.http.get("www.google.com");
  }
}

Thanks in advance!

Pass Success Message from PHP to HTML page after validation

I’m tiring to Pass a success message after pup checks the database and confirms the data
how do I display a message in case of a wrong password entry ,I tried many solutions with no success ,I tried using ajax solutions and JavaScript with no success as I don’t know the basics on ajax and my background in JavaScript is basic
Here’s my code

LoginTest.html

<html>
<link rel="stylesheet" href="LoginStyle.css">
<head>
    <title>Login</title>
</head>

<body>

    <div class="login-box">
        <h2>Login</h2>
        <form action="http://localhost/Test2/dbloginTest.php" method="post" name="loginform" class="loginform">
            
            <div class="user-box">
                <input type="number" name="civilid" required="">
                <label>Civil ID</label>
            </div>

            <div class="user-box">
                <input type="password" name="password" required="">
                <label>Password</label>
                
            </div>
            <input type="submit" name="submit" Value="Login">
        </form>
        
        <a href="Registration.html">
            <input type="submit" name="register" Value="Register">
        </a>

    </div>


</body>

</html>

dbloginTest.php

   <?php
require 'C:WindowsSystem32vendorautoload.php';
if (isset( $_POST['submit'] ) && isset( $_POST['civilid'] ) && isset( $_POST['password'] ) ) {

    $civilid = ( $_POST['civilid'] );
    $password = ( $_POST['password'] );
    $hashpass = "";
    $return = array();
    //echo extension_loaded( "mongodb" ) ? "loadedn" : "not loadedn";
    $con = new MongoDBClient( 'mongodb+srv://Admin:[email protected]/?retryWrites=true&w=majority' );
    // Select Database
    if ( $con ) {
        $db = $con->VoterDatabase;
        // Select Collection
        $collection = $db->Voters;
        $cursor = $collection->find( array( 'civilid' => $civilid ) );
        foreach ( $cursor as $row ) {
            ob_start();
            echo $row->password;
            $hashpass = ob_get_clean();
        }
        
       
        if ( password_verify($password,$hashpass) ) {
            echo "You Have Successully Logged In";
            header( 'Location:Voters.html' );
            exit;
        } else {
            
            echo "Your Civil ID or Password is Incorrect";
            header( 'Location:LoginTest.html' );
            exit;
        }
    } else {

        die( "Mongo DB not connected" );
    }
}
?>

Carrying an array from an AJAX call into an additional, nested AJAX Call

Using the Rick & Morty API to create a website that, given x characters, will return episodes that contain all x characters.

   $.ajax(url1)
    .then ((info1) => {
        char1Episodes = info1.results[0].episode
        
    })

this stores the array of episodes for a given character into a variable char1Episodes….how do I then take that into another AJAX call to compare it against an array of the second character’s episodes to check for any duplicates using a for loop, thus signifying episodes they share?

Changing the position of a sphere in P5.js

By default, it seems like a sphere object in P5 is located at (0,0). I want to create an object that is visually represented by a sphere with the ability to define the x and y coordinates of the sphere object.

Because I want to deal with multiple of these objects and draw connections between them, I don’t want to use the translate function for a sphere to position it every time. Is there a way to position the sphere to the coordinates I want without the translate function?

setInterval (if text then click) then start a new clean setInterval

im new at js/node. I don’t figured out how to build this code properly. I’ve tried several ways.
The countdown that restarts by itself every 10s. It clicks only rarely, even if I decrease the ms.
The function must start after the chrome load in console as script, doesn’t required HTML
Here is the base code. THX!!!

setInterval(function () {
  if (
    document.querySelector("div.text-countdown-progressbar").textContent === "0"
  ) {
    document.querySelector("a.button").click();
  }
}, 1000);

declare X-Total-Count in the Access-Control-Expose-Headers header

hello I tried to use react-admin to display my API but I found this error

<–The X-Total-Count header is missing in the HTTP Response. The simple REST data provider expects responses for lists of resources to contain this header with the total number of results to build the pagination. If you are using CORS, did you declare X-Total-Count in the Access-Control-Expose-Headers header?—->
this is my backend code :

const PORT = 8000
const axios = require('axios')
const cheerio = require('cheerio')
const express = require('express')
const app = express()
const cors = require('cors')
app.use(cors())

const url= 'https://flyvide.com/airport/NCE'



//app.METHOD(PATH, HANDLER)

app.get('/', function (req,res)  {
    res.json('This is my webscrapper')
   
})



app.get('/results', (req,res) =>{
 
    axios(url)
    .then(response => { 
      
        const html= response.data
        const $ = cheerio.load(html)
        const articles = []
        $('div > div > a > div' , html).each(function() {
            direction = $(this).find("div > div.col-4.d-none.d-md-block > h5").text();
            date = $(this).find("h5:nth-child(2)").text();
            time = $(this).find("div.col-2.d-none.d-md-block > div > h5").text();
            price = $(this).find("div.price.d-none.d-md-block > div > h4").text();
      
            articles.push({
                direction, date,time, price
                //urls
        })
       
            
        })
        //console.log(articles)
        res.json(articles)
    }).catch(err => console.log(err))

})



app.listen(PORT, () => console.log(`server running on PORT ${PORT}`))

Import typeahead.js With Webpacker

I’m trying to use Twitter Typeahead in a Rails 7 project with Webpacker. I had it working when I included it via CDN, but for various build reasons I would like to stop using the CDN. I have installed it into the project with yarn add typeahead.js. I can import typeahead to webpacker with import 'typeahead.js'; but I still get Uncaught ReferenceError: Bloodhound is not defined in my chrome console. I can see the Bloodhound file on yarnpkg https://yarnpkg.com/package/typeahead.js?files but I can’t get my app to reference it. import Bloodhound from 'typeahead.js'; and import Bloodhound from 'typeahead.js/dist/bloodhound'; do not work.

I have little experience with JS or webpacker. Any help would be appreciated!

Webpack “Cannot find module ‘fs’ “

I’ve been banging my head over my table trying to figure out whats wrong here, and I need some help pls :’)

I’m trying to convert a CSV file to JSON, and all of the packages seem to use something called “fs”. I’ve searched the web and tried all of the following fixes, but nothing seems to work. I’m using webpack 5.74 btw.

Node cannot find module “fs” when using webpack

https://github.com/webpack-contrib/css-loader/issues/447

https://jasonwatmore.com/post/2021/07/30/next-js-webpack-fix-for-modulenotfounderror-module-not-found-error-cant-resolve

No matter what I try, I always get the “Cannot find module ‘fs'” error.

Does anyone have an idea of what this could be, since I’ve tried all of the possible solutions in the links above?

Any help would be much appreciated! Thank you!

react-dnd monitor.didDrop() is always false in returned collected props

I am having real trouble finding the problem here, but at the same time, I am pretty sure it’s not a problem with react-dnd directly, but the implementation details of the react components.

I am posting the codesandbox link that I have reproduced the same issue from my code.
The strange part here is that canDrop and isOver and all the other parts are working as expected, the only problem here is monitor.didDrop().

I have already tested a lot of cases and it’s not an issue with a specific version of the libraries.

Reproduced version