How can I solve this error? “export ‘default’ (imported as ‘App’) was not found in ‘./App’ (possible exports: App)” (im using react)

heyyy. i wanted to try out react with this tutorial.

at the moment I have only made the data structure. unfortunately i always get an error when compiling.


Error

Compile failed.

Attempted import error: './App' does not contain default export (imported as 'App').
Assets by state 1.6 MiB [cached] 2 assets
Assets by path . 930 bytes
  asset index.html 658 bytes [emitted]
  asset-manifest.json 272 bytes [emitted]
cached modules 1.39 MiB (javascript) 1 bytes (asset) 28.1 KiB (runtime) [cached] 144 modules
./src/index.js 1.34 KiB [built]

ERROR in ./src/index.js 8:38-41
export 'default' (imported as 'App') was not found in './App' (possible exports: App)

webpack 5.66.0 compiles with 1 error in 63 ms

App.js

import React from 'react'

import { Footer, Blog, Possibility, Features, WhatWELOVEU, Header } from './containers';
import { CTA, Brand, Navbar } from './components';

export const App = () => {
    return (
        <div className='App'>
            <div className='gradient_bg'>
                <Navbar />
                <Header />
            </div>
            <Brand />
            <WhatWELOVEU />
            <Features />
            <Possibility />
            <CTA />
            <Blog />
            <Footer />

            
        </div>
    )
}

index.js

import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));

these two files are in the “src” folder. in the “src” folder there are also the components and containers. everything is described in the tutorial and the data structure is the same.
enter image description here


In the folder components and container are .jsx and css files. all css FIles nid empty, in the jsx files you can find the same code always adapted to the name of the file.

p.ex.
Article.jsx

import React from 'react'
import './article.css';

const Article = () => {
    return (
        <div>
            Article
        </div>
    )
}

export default Article

enter image description here


In containers and components are also index files.

components/index.js

export { default as Article } from './article/Article';
export { default as Brand } from './brand/Brand';
export { default as CTA } from './cta/CTA';
export { default as Feature } from './feature/Feature';
export { default as Navbar } from './navbar/Navbar';

containers/index.js

export { default as Blog } from './blog/Blog';
export { default as Features } from './features/Features';
export { default as Footer } from './footer/Footer';
export { default as Header } from './header/Header';
export { default as Possibility } from './possibility/Possibility';
export { default as WhatWELOVEU } from './whatWELOVEU/whatWELOVEU';

How to create a new page and route programatically in React.js with React Router

I’m building a blog website with React.js with React-router. I have a “blog.js” file that renders all titles of the blogs the page looks like this:

Blog.js

    function Blog() {
    
    
      return (
        <div>
          <Header />
          <div className="blog-page-title">
          <h1>Blog</h1>
          </div>
          <div className="blog">
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
            <Articles title="Title" text="lorem ipsum dolor amet" />
      
          </div>
          <Footer />
        </div>
      );
    }

export default Blog;

enter image description here

When I click on the title, it should route to the corresponding article. But do I have to create a new Route and a new js file manually for each article to achieve this? For instance, can I do something like whenever there is a new Articles component in blog.js it will go and create a new route and a js file automatically?

Decode Base64 with UCS-2 Encoding

I want to decode the Base64 result of MS-SQL Server in javascript, but I can’t find a true solution. I know SQL Server uses UCS-2 encoding, and I have to use the same encoding to decode in javascript.

For example, for MwZEBicGRQY= the encoded result must be سلام.

Do you have any solution to decode that using javascript?

Build a class that have 3 instances variables : itemname, quantity and price

1.Build a class that have 3 instances variables : itemname, quantity and price. Build a method that can input number of item bought by a customer in XYZ supermarket. (add suitable exception handling type to make sure user input the correct number); itemname, quantity and price will be insert based on number of item bought. (use looping statement) and calculate total price to be paid. Build another method to calculate the total price

Integrating DHL Rates API in ReactJs using NodeJs

I want to integrate DHL API into my react js website using node js with express. I have written the backend code and the front end code that would allow me to do this, but when I try to check the rates for a shipment, it gives me this error "Error: Request failed with status code 500"

I don’t know what I am doing wrong when trying to get the DHL API to work.

here is my code:

CheckRates.js:

    const [fromCountires,setFromCountries] = useState("");
    const [fromCountriesCode,setFromCountriesCode] = useState("");
    const [fromCountriesCapital,setFromCountriesCapital] = useState("");
    const [toCountries,setToCountries] = useState("");
    const [toCountriesCode,setToCountriesCode] = useState("");
    const [toCountriesCapital,setToCountriesCapital] = useState("");
    const [weight,setWeight] = useState("");



const getRateEstimate = () => {
                

      const options = {
        method: 'GET',
        url: "http://localhost:3001/api/dhl",
        params: {
          accountNumber: 'myaccountnumber',
          originCountryCode: fromCountriesCode,
          originCityName: fromCountriesCapital,
          destinationCountryCode: toCountriesCode,
          destinationCityName: toCountriesCapital,
          weight: weight,
          length: '5',
          width: '5',
          height: '5',
          plannedShippingDate: date,
          isCustomsDeclarable: 'false',
          unitOfMeasurement: 'metric',
          
        },
        headers: {
          Authorization: 'Basic myauth',  
        }
      };
     
        axios.request(options).then((response) => {
            console.log(response.data);
            setData(response.data);
        }).catch((error) => {
            console.error(error);
        });
      }

nodejs server, index.js:

require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const mysql = require('mysql');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const multer = require('multer');
const path = require('path');
const request = require('request');
const port = 3001
const app = express();

//Middleware 

app.use(cors({
    origin: '*',
    credentials: true,
    methods: ['GET', 'PUT', 'POST'],
    allowedHeaders: ['Content-Type', 'Authorization']
}));
app.use(express.json());
app.use(bodyParser.urlencoded({extended: true}));

app.get("/",(req,res) => {
  res.send("Root App");
})

app.get('/api/dhl', (req, res) => {
  
  request(
    {url: 'https://express.api.dhl.com/mydhlapi/test'},
    (error, response, body) => {
      if (error || response.statusCode !== 200) {
        return res.status(500).json({ type: 'error', });
      }
      res.json(JSON.parse(body));
    }
  )
});

querySelectorAll for multiple objects

I have this code, i need to change JS code for use it on all navigation class names. The purpose is to create a drop down menu but the javascript code takes only the first of the elements with class name navigation.

On inquiring I found out we need to use a querySellectorAll but I can’t get it to work.

I give you below the code that works for only one object hoping someone will be able to show me how to use it for all objects with class name navigation. Thanks for your help.

let navigation = document.querySelector('.navigation');

navigation.onclick = function() {
  navigation.classList.toggle('active')
}
.active {
  color: blue;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

<div class="navigation">
  <ul>
    <span><i class="fa-regular fa-pen-to-square"></i></span>
    <span><i class="fa-regular fa-heart"></i></span>
    <span><i class="fa-regular fa-trash-can"></i></span>

    <div id="marker"></div>
  </ul>
</div>
<div class="navigation">
  <ul>
    <span><i class="fa-regular fa-pen-to-square"></i></span>
    <span><i class="fa-regular fa-heart"></i></span>
    <span><i class="fa-regular fa-trash-can"></i></span>

    <div id="marker"></div>
  </ul>
</div>
<div class="navigation">
  <ul>
    <span><i class="fa-regular fa-pen-to-square"></i></span>
    <span><i class="fa-regular fa-heart"></i></span>
    <span><i class="fa-regular fa-trash-can"></i></span>

    <div id="marker"></div>
  </ul>
</div>

Discord.JS Send all Embeds from Array

multiple embed pushed in array but i need write them in send message without writing specific number Embeds[0], Embeds[1] and more …

i cant find a way.

let Embeds = [];

Embeds.push(new MessageEmbed()
   .setTitle("title")
   .setColor("#3d9e00")
   .setDescription("TEST"));

msg.channel.send({
   embeds: [Embeds[0], Embeds[1]]
});

React not redirecting as intended when A function is called in the Routes route

I am building a login and logout system for a react project of mine. I have a navbar setup and I am using react-redirect-dom to create links and redirect links to different pages in order to manage the login system.

In the current project, I have a route that does the processing for the login in the login component. I have another link that processes the signup within the signup component.

For the logout, If a user is logged in and they use the /logout endpoint, I want it to immediately call the handleLogout function and log the user out and reroute to the / endpoint

Here is the code I have and the error:

function App() {

  const [loggedIn, setLoggedIn] = useState(false)
  const [currentUser, setCurrentUser] = useState('')

  function handleLogout() {
    console.log('handle logout')
    axios.post('/api/auth/logout', {
      "username":currentUser.username,
      "password":currentUser.password,
    })
    .then((data) => {
      console.log(data.data)
      setCurrentUser(data.data)
      setLoggedIn(false)
      return(<Navigate to='/' />)
    })
    .catch((err) => {
      console.log(err)
    })
  }

  return (
    <div className="App">
      {/* <ContentContext value={contentContextValue}> */}
        <BrowserRouter>
          <Routes>
              <Route exact path="/" element={loggedIn ? <Feed/> : <Login setLoggedIn={setLoggedIn} setCurrentUser={setCurrentUser}/>} />
              <Route exact path="/login" element={<Login setLoggedIn={setLoggedIn} setCurrentUser={setCurrentUser}/>}/>
              <Route exact path="/signup" element={<Login setLoggedIn={setLoggedIn} setCurrentUser={setCurrentUser}/>}/>
              <Route exact path="/logout" element={loggedIn ? () => {handleLogout()} : <Login/>}/>
            </Routes>
        </BrowserRouter> 
      {/* </ContentContext> */}
    </div>
  );
}

Here is the error:

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.

The text is disappearing when i added the image

The text like “welcome” are not appearing when I added the av

<!DOCTYPE html>
<html>
    <style>
        @font-face {
            font-family: OpenSans;
            src: url(OpenSans-Bold.ttf);
         }
         
         * {
            font-family: OpenSans;
         }

    </style>
<body>
  <canvas id="myCanvas" width="1024" height="500" style="border:1px solid #d3d3d3;">
    Your browser does not support the canvas element.
  </canvas>

  <script>
    var canvas = document.getElementById("myCanvas");
    var background = new Image();
    background.src = "https://i.imgur.com/ua7gL3M.png";
    let av = new Image();
    av.src = "https://cdn.discordapp.com/avatars/852848188942581764/6b54aba527059f96ecdcb06763d89dac.png?size=4096"

    // Make sure the image is loaded first otherwise nothing will draw.
    background.onload = function(){
        ctx.drawImage(background,0,0); 

        // The following lines were moved into the onload callback
        ctx.beginPath();
        ctx.arc(512,160,120,0,2*Math.PI);
        ctx.strokeStyle = "red"
        ctx.lineWidth = 15;
        ctx.stroke();
        ctx.closePath();
        ctx.clip();
        
        ctx.drawImage(av, 390, 40, 250, 250);

        ctx.beginPath();
        ctx.arc(405,160,120,0,2*Math.PI,true)
        ctx.clip();
        ctx.closePath();
        ctx.restore();
        //welcome
        ctx.fillStyle = "#00ffff";
        ctx.font = "90px OpenSans";
        ctx.shadowColor="black";
        ctx.shadowOffsetX = 3;
        ctx.shadowOffsetY= 3;
        ctx.shadowBlur= 10;
        ctx.textAlign = "center"
        ctx.fillText("WELCOME", (canvas.width / 2) , 360 );
        //username
        ctx.fillStyle = "#2ffa76";
        ctx.font = "50px OpenSans";
        ctx.shadowColor="black";
        ctx.shadowOffsetX = 3;
        ctx.shadowOffsetY= 3;
        ctx.shadowBlur= 10;
        ctx.textAlign = "center"
        ctx.fillText("Haruke#0001",(canvas.width / 2), 415);
        //thanks
        ctx.fillStyle = "#5076ff";
        ctx.font = "35px OpenSans";
        ctx.shadowColor="black";
        ctx.shadowOffsetX = 3;
        ctx.shadowOffsetY= 3;
        ctx.shadowBlur= 10;
        ctx.textAlign = "center"
        ctx.fillText("Thanks For Joining!!",(canvas.width / 2), 460);
    }
    var ctx = canvas.getContext("2d");
  </script>

</body>

</html>

HTML5 Video autoplay with sound unmuted

I need to implement a local autoplay video on my website. Still, I knew that newer browsers, i.e., Chrome, Mozilla, and Safari, have blocked autoplay when the video has no ‘muted’ attribute.
So,
Is there any way to autoplay the video unmuted(with sound) in HTML5 by any trick in HTML or Javascript?
Since, When I remove the ‘muted’ attribute, The video stops from autoplay by the Browser.

Here is the simple HTML5 code I use:

<body>
<div class="video-wrapper">
<video autoplay muted loop playsinline preload="metadata">
  <source src="EDMVideo(Jay)_NEW.webm">
</video>
</div>
</body>

Javascript fetch fails to call localhost

I cannot let javascript fetch a localhost

contentAPI.php

<?php
echo 'en';
?>

curl call

curl http://localhost:8000/CONTENT/contentAPI.php

curl result

en

javascript call

fetch("http://localhost:8000/CONTENT/contentAPI.php")
        .then(function(response) {
            return response.text();
        })
        .then(function(responseText) {
            alert(responseText);
        })
        .catch(function(err) {
            alert(err);
        });

javascript result

TypeError: Failed to fetch

Any help?

On iOS, is there a way to detect a web page runs in the embedded browser and open the “real” one?

My web site uses magic links for login, however, I have a problem on mobile (not sure about Android – haven’t tried yet, but the problem exists at least on iOS): when a user receives the email say in the GMail app, the link opens in the embedded browser, meaning that cookies will not be passed to the “real” browser.

Is there a way to ensure the link in the email opens in the real system browser and therefore cookies are stored permanently?

(Essentially browser session isolation on iOS breaks a lot of things on the Internet, so surely there is a workaround?)

How do you solve a mathematical equation without using document.write?

Here is my code –

Inputting the following metrics:

Frame Width:  16
Frame Height:  20 
Picture Width:  11 
Picture Height:  17 
Mat Overlap:  .25

…produces the following output: 1.6252.625 due to not writing HTML after the calculation is made, thus should be:

Width = 1.625
Height = 2.625

{

    margin:0;

    padding: 0;

    font-family: 'Lato', sans-serif;

  }



  /*Fieldset and legend */

   fieldset {

     margin: 2em 0;

     padding: 1em 2em;

     border: solid 1px #ccc;

     border-radius: 6px;

     min-width:P 200px;

   }



   legend {

     font-size: 1.25em;

     padding: 0 .25em;

     color: #999;

   }



   /* Labels */

    label{

      display: block;

      margin-top: 1em;

    }



    .checks label {

          margin-top: 0;

       }



    label:first-of-type {

      margin-top: 0;

    }



    /* Inputs and textarea */

     input {

         padding: .5em;

         border: solid 1px #999;

         background-color: #D3D3D3

     }



     input[type="number"], input[type="text"] {

         width:  15em;

         background-color: #D3D3D3

     }



     textarea {

         min-height: 8em;

         min-width: 100%;

         padding: .5em;

         border: solid 1px #999;

         background-color: #D3D3D3

     }



     /* radio buttons and checkboxes */

      .checks {

        margin-bottom: 1em;

      }



      .checks p {

        margin-bottom: 0;

      }



      input[type="checkbox"] + label, input[type="radio"] + label

      {

        display: inline-block;

        padding-top: 0;

        margin-top: 0;

      }



      input[type="radio"] {

        margin-left: 1.5em;

        margin-right: 0;

      }



      input[type="radio"]:first-of-type {

        margin-left: 0;

      }

      #dvemail {
        display: none;
      }
      #chkYes:checked ~ #dvemail {
        display: block;
      }



      /* Submit Button */

       input[type="button"] {

         padding: .5em 1em;

         border-radius: 6px;

         background-color: #333;

         color: #fff;

         font-family: 'Lato', sans-serif;

         font-size: .8em;

       }



       /* Large screen rules */

       @media screen and (min-width: 430px) {

            legend {

              font-size: 1.75em;

            }



            fieldset {

              width: 40%;

              min-width: 320px;

              margin: auto;

            }



            .checks label {

              display: inline-block;

              padding-top: .5em;

              margin-top: 0;

              margin-right: .5em;

            }

       }
<!DOCTYPE html>

<html lang="en">

    <head>
    
        <meta charset="UTF-8">

        <meta name "viewport" content="width=device-width,

        initial-scale=1.0">

        <title>I Was Framed - Calculator</title>



        <link href="https://fonts.googleapis.com/css?family=Lato:300,400,400i,700,900&display=swap" rel="stylesheet">

        <link rel="stylesheet" href="style.css">

    </head>

<body>

<section>

<form id="frm1" action="form_action.asp">

<fieldset>

<legend>

I Was Framed Calculator

</legend>



<label for="frameWidth">Frame Width:</label><input type="number" step="any" min="0" name="wf" id="wf">

<label for="frameHeight">Frame Height:</label><input type="number" step="any" min="0" name="hf" id="hf"><br>

<label for="pictureWidth">Picture Width:</label><input type="number" step="any" min="0" name="wp" id="wp">

<label for="pictureHeight">Picture Height:</label><input type="number" step="any" min="0" name="hp" id="hp"><br>

<label for="matOverlap">Mat Overlap:</label><input type="number" min="0" step="any" name="o" id="o"><br>

<div class="checks">
<br>
Email results? &nbsp&nbsp
    <input type="radio" id="chkYes" name="chk" />
    <label for="chkYes">Yes</label>
    
    <input type="radio" id="chkNo" name="chk" />
    <label for="chkNo">No</label>
    <div id="dvemail">
<br>
        Email:
        <input type="email" id="email" /><br>
        <label for="msg">Note:</label>
        <textarea name="msg" id="msg"></textarea>
    </div>

</div>

<input type="button" onclick="calc()" value="Calculate"/>

</fieldset>

</form>

</section>

<script>

function calc()

{

var wf = document.getElementById('wf').value

var hf = document.getElementById('hf').value

var wp = document.getElementById('wp').value

var hp = document.getElementById('hp').value

var o = document.getElementById('o').value

Width:  document.write((1/2)*(hf-hp+o));
Height: document.write((1/2)*(wf-wp+o));

}

</script>

</body>

</html>

I’m specifically wanting to solve the following two equations based on user input:

Width:  document.write((1/2)*(hf-hp+o));
Height: document.write((1/2)*(wf-wp+o));

But I want to avoid using document.write completely because I can’t seem to .write HTML after the calculation to have the output of my calculator look presentable. Respectfully, what should I use instead and how with my code provided?

I have also looked at JavaScript eval() but it asserts –

Do NOT use eval(). due to security issues.