React router dom 6: go back without reloading

I’m integrating MUI Tabs with React Router (Dom) Link to achieve a layout that looks something like the following:

enter image description here

Sandbox here

When I switch tabs the url changes. This also happens when using the navigate() method provided by react-native-hooks.

I’m trying to prevent the component re-rendering both when I switch between tabs and when I use navigate(-1).

Is there a built-in way provided by react-router-dom or I’m I supposed to implement the behaviur myself?

How to draw direction map through google API if we have more then 25 (way points)

I am working on a Google direction map, where I have to show Employee tracking map, but my problem is when I am getting 25 way points, map is working perfect but beyond then 25 way points I am getting way points exceed error. Below are my code which is working in 25 way points,

    function initialize() {
        directionsDisplay = new google.maps.DirectionsRenderer({ suppressMarkers: true });
        if (jQuery('#map').length > 0) {
            map = new google.maps.Map(document.getElementById('map'), {
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                scrollwheel: false
            });
            directionsDisplay.setMap(map);

            var infowindow = new google.maps.InfoWindow();
            var flightPlanCoordinates = [];
            var bounds = new google.maps.LatLngBounds();

            var locations = jQuery.parseJSON(MapPoints);
            if (locations.length <= 0) {
                $('.trakingNav').hide();
                $('#map').hide();
                $('.No_Data_Available').show();
                return;
            }
            $('.trakingNav').show();
            $('#map').show();
            $('.No_Data_Available').hide();
            var imageMiddle = '<%= ResolveClientUrl("~/img/routePoint.png")%>';  
            var imageS = '<%= ResolveClientUrl("~/img/eapro_map_icon_S.png")%>'; // This is for starting point
            var imageE = '<%= ResolveClientUrl("~/img/eapro_map_icon_E.png")%>'; // This is for end point
            const partsFirst = locations[0].LocationTime.split(/[/ :]/);
            const ConvertTimeFirst = `${partsFirst[1]}/${partsFirst[0]}/${partsFirst[2]} ${partsFirst[3]}:${partsFirst[4]}`;
            divStartTime.innerHTML = ConvertTimeFirst;

            const partsCurrent = locations[locations.length - 1].LocationTime.split(/[/ :]/);
            const ConvertTimeCurrent = `${partsCurrent[1]}/${partsCurrent[0]}/${partsCurrent[2]} ${partsCurrent[3]}:${partsCurrent[4]}`;
            divCurrentTime.innerHTML = ConvertTimeCurrent;

            divCurrentAddress.innerHTML = locations[locations.length - 1].address.address;
            // when locations.length is less then or equal to 25, it Google direction map is perfect , but
            // when more then 25 its showing maximum limit exceed error, and I am not able to draw map
            for (i = 0; i < locations.length; i++) {
                if (i == 0) {
                    marker = new google.maps.Marker({
                        position: new google.maps.LatLng(locations[i].address.lat, locations[i].address.lng),
                        map: map,
                        animation: google.maps.Animation.DROP,
                        icon: imageS
                    });
                }
                else if (i == (locations.length - 1)) {
                    marker = new google.maps.Marker({
                        position: new google.maps.LatLng(locations[i].address.lat, locations[i].address.lng),
                        map: map,
                        animation: google.maps.Animation.DROP,
                        icon: imageE
                    });
                }
                else {
                    marker = new google.maps.Marker({
                        position: new google.maps.LatLng(locations[i].address.lat, locations[i].address.lng),
                        map: map,
                        animation: google.maps.Animation.DROP,
                        icon: imageMiddle
                    });
                }
                flightPlanCoordinates.push(marker.getPosition());
                bounds.extend(marker.position);

                google.maps.event.addListener(marker, 'click', (function (marker, i) {
                    if (!infowindow) {
                        infowindow = new google.maps.InfoWindow();
                    }
                    var geocoder = geocoder = new google.maps.Geocoder();
                    var ltlng = [];
                    ltlng.push(new google.maps.LatLng(locations[i].address.lat, locations[i].address.lng));
                    return function () {
                        const parts = locations[i]['LocationTime'].split(/[/ :]/);
                        const ConvertTime = `${parts[1]}/${parts[0]}/${parts[2]} ${parts[3]}:${parts[4]} ${parts[6]}`;
                        infowindow.setContent("Engineer Name: " + locations[i]['title'] +
                            ", <br/>Location: " + locations[i].address.address +
                            ", <br/>Location Time: " + ConvertTime +
                            ", <br/>Battery: " + locations[i]['battery']);
                        infowindow.open(map, marker);
                    }
                })(marker, i));
            }

            map.fitBounds(bounds);

            // directions service
            var start = flightPlanCoordinates[0];
            var end = flightPlanCoordinates[flightPlanCoordinates.length - 1];
            var waypts = [];
            for (var i = 1; i < flightPlanCoordinates.length - 1; i++) {
                waypts.push({
                    location: flightPlanCoordinates[i],
                    stopover: true
                });
            }
            //console.log(start, end, waypts);
            calcRoute(start, end, waypts);
        }
        else {
            alert('No data available');
        }
    }

// Below function is use for calculating distance in KM.
    function calcRoute(start, end, waypts) {
        var request = {
            origin: start,
            destination: end,
            waypoints: waypts,
            optimizeWaypoints: true,//false for our given orde and true for auto optimized
            travelMode: google.maps.TravelMode.DRIVING  //DRIVING, WALKING, BICYCLING, TRANSIT
        };
        directionsService.route(request, function (response, status) {


            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
                var summaryPanel = document.getElementById('directions_panel');
                summaryPanel.innerHTML = '';
                var distancevalue = 0;

                for (var i = 0; i < response.routes.length; i++) {
                    var route = response.routes[i];

                    for (var i = 0; i < route.legs.length; i++) {

                        distancevalue += route.legs[i].distance.value;

                    }
                }


                distancevalue = distancevalue / 1000;

                summaryPanel.innerHTML += distancevalue.toFixed(2) + ' KM ';
                $('.trakingNav').show();
            }
        });
    }

I also tried spilt my way points in 25 chunks and call direction map API, but did not success, I change my code as below,

// directions service
                var summaryPanel = document.getElementById('directions_panel');
                summaryPanel.innerHTML = '';                
                if (flightPlanCoordinates.length <= 25) {
                    var start = flightPlanCoordinates[0];
                    var end = flightPlanCoordinates[flightPlanCoordinates.length - 1];
                    var waypts = [];
                    for (var i = 1; i < flightPlanCoordinates.length - 1; i++) {
                        waypts.push({
                            location: flightPlanCoordinates[i],
                            stopover: true
                        });
                    }
                    //console.log(start, end, waypts);
                    var distancevalue=calcRoute(start, end, waypts);
                    summaryPanel.innerHTML += distancevalue  + ' KM ';
                    $('.trakingNav').show();
                }
                else {
                    var distancevalue = 0;
                    var length = flightPlanCoordinates.length;
                    //console.log("length " + length);
                    var totalCycle = parseInt(length / 25);
                    //console.log("totalCycle " + totalCycle);
                    for (var o_i = 0; o_i < totalCycle; o_i++) {
                        var start = flightPlanCoordinates[o_i * 23];
                        var end = flightPlanCoordinates[(o_i + 1) * 23 - 1];
                        var waypts = [];
                        //console.log("Start " + start);
                        //console.log("end " + end);
                        for (var i = (o_i * 23) + 1; (i < (o_i + 1) * 23) && (i < length); i++) {
                            waypts.push({
                                location: flightPlanCoordinates[i],
                                stopover: true
                            });
                            //console.log("Value of o_i & i " + o_i + " & " + i);
                        }
                        //console.log(start, end, waypts);
                        distancevalue = calcRoute(start, end, waypts);
                        console.log(distancevalue);
                    }
                    summaryPanel.innerHTML = distancevalue  + ' KM ';
                    $('.trakingNav').show();

How to click outside the element and allow the container fade instantly using JQuery

I am having 2 menu (Notification and Badge like stackoverflow website)
If I click the notification, my badge container should fade and vice versa.

But currently I can find the notification container is not fading when I click on badge instead its overlapping.
Following is my html code,

<div class="wishlist-dropsec" id="badge_notification_list">
                <span id="badge_notificationLink"><i class="fa fa-trophy"></i><strong id="badge_notification_countt"></strong>
                </span>
                <div id="badge_tooltip">
                    <div id="badge_notificationContainer">
                        <div id="badge_notificationsBody" class="notifications"></div>
                    </div>
                </div>
            </div>

            <div class="wishlist-dropsec" id="notification_list">
                <span id="notificationLink"><i class="fa fa-bell"></i><strong id="notification_countt"></strong>
                </span>
                <div id="tooltip">
                    <div id="notificationContainer">
                        <div id="notificationsBody" class="notifications"></div>
                    </div>
                </div>
            </div>

Following is my JQuery code,

<script type="text/javascript" >
$(document).ready(function()
{

//Document Click hiding the popup 
$(document).click(function()
{
$("#notificationContainer").hide();
$("#tooltip").hide();
});

//Popup on click
$("#notificationContainer").click(function()
{
return false;
});

//Document Click hiding the popup 
$(document).click(function()
{
$("#badge_notificationContainer").hide();
$("#badge_tooltip").hide();
});

//Popup on click
$("#badge_notificationContainer").click(function()
{
return false;
});


});
</script>

react-paypal-button-v2 keeps loading forever

the paypal button just keeps loading forever and I’m new and this is my first project so I don’t really know how to fix this

these are the codes

  useEffect(() => {
    const addPayPalScript = async () => {
      const { data: clientId } = await axios.get('api/config/paypal');
      const script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = `https://www.paypal.com/sdk/js?client-id=${clientId}`;
      script.asyc = true;
      script.onload = () => {
        setSdkReady(true);
      };
      document.body.appendChild(script);
    };
    if (!order || successPay) {
      dispatch({ type: ORDER_PAY_RESET });
      dispatch(getOrderDetails(orderId));
    } else if (!order.isPaid) {
      if (!window.paypal) {
        addPayPalScript();
      } else {
        setSdkReady(true);
      }
    }
  }, [dispatch, orderId, successPay, order]);

  const successPaymentHandler = (paymentResult) => {
    console.log(paymentResult);
    dispatch(payOrder(orderId, paymentResult));
  };

this is the code for paypal button, it’s the one showing the paypal button

{!order.isPaid && (
    <div className="col-12">
        {loadingPay && <Loading />}
        {!sdkReady ? (
            <Loading />
        ) : (
            <PayPalButton
            amount={order.totalPrice}
            onSuccess={successPaymentHandler}
            />
        )}
    </div>
)}

Phaser GameObjectFactory function is undefined

I am using GameObjectFactory to register myPlayer

import Phaser from 'phaser'
import Player from './Player'
import { Direction } from '@/types/phaser';

export default class MyPlayer extends Player {
  constructor(
    scene: Phaser.Scene,
    x: number,
    y: number,
    defaultDirection: Direction
  ) {
    super(scene, x, y, defaultDirection)
    scene.add.existing(this)
  }
}

declare global {
  namespace Phaser.GameObjects {
    interface GameObjectFactory {
      myPlayer(x: number, y: number, defaultDirection: Direction): MyPlayer
    }
  }
}

Phaser.GameObjects.GameObjectFactory.register(
  'myPlayer',
  function (
    this: Phaser.GameObjects.GameObjectFactory,
    x: number,
    y: number,
    defaultDirection: Direction
  ) {
    const sprite = new MyPlayer(this.scene, x, y, defaultDirection)

    this.displayList.add(sprite)
    this.updateList.add(sprite)

    return sprite
  }
)

I try to use this.add.myPlayer in my scene

import Phaser from 'phaser'
import MyPlayer from '@/players/MyPlayer'
import { CustomCursorKeys } from '@/types/phaser'
import { Direction } from '@/types/phaser'

export default class BaseScene extends Phaser.Scene {
  public cursors: CustomCursorKeys | null = null
  public myPlayer: MyPlayer | null = null

  constructor(key: string) {
    super(key)
  }

  create(param: { 
    map: Phaser.Tilemaps.Tilemap, 
    x: number, 
    y: number, 
    direction: Direction 
  }) {
    console.log('this.add.myPlayer', this.add.myPlayer)
    this.myPlayer = this.add.myPlayer(705, 500, 'up')
  }
}

But this.add.myPlayer console logs as undefined. What am I doing wrong?

Third party javascript + iframe insertion

I have created a third party script which is inserting iframes with indiviual html controls like (username [type input] & password [type password]).These html controls are dynamic and can change on the basis of input given by user from publisher website to third party script.

I am now struggling with getting these values from indiviual iframes to my third party script. I am not able to find solution for this problem.

Note: I am using indiviual iframes for each input control because publisher want to apply css from their end on each iframe html control. They are not willing to share the css to us and purpose of inserting iframe from third party script is, customer not allowed to access the user data entered inside iframe input controls.
I am also sharing the html view of my poc to show, how the page looks with iframe insertion from third party script.
[enter image description here][1]
[1]: https://i.stack.imgur.com/Mrtgb.jpg

How can I convert the binary data for a JPEG to the actual image using JS?

I have some binary data for a JPEG image that I want to display on my website (the image should just be all white; nothing interesting).

xffxd8xffxe0x00x10JFIFx00x01x01x01x00`x00`x00x00xffxdbx00Cx00x08x06x06x07x06x05x08x07x07x07ttx08nx0cx14rx0cx0bx0bx0cx19x12x13x0fx14x1dx1ax1fx1ex1dx1ax1cx1c $.' ",#x1cx1c(7),01444x1f'9=82<.342xffxdbx00Cx01tttx0cx0bx0cx18rrx182!x1c!22222222222222222222222222222222222222222222222222xffxc0x00x11x08x01xa4x01xa4x03x01"x00x02x11x01x03x11x01xffxc4x00x1fx00x00x01x05x01x01x01x01x01x01x00x00x00x00x00x00x00x00x01x02x03x04x05x06x07x08tnx0bxffxc4x00xb5x10x00x02x01x03x03x02x04x03x05x05x04x04x00x00x01}x01x02x03x00x04x11x05x12!1Ax06x13Qax07"qx142x81x91xa1x08#Bxb1xc1x15Rxd1xf0$3brx82tnx16x17x18x19x1a%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzx83x84x85x86x87x88x89x8ax92x93x94x95x96x97x98x99x9axa2xa3xa4xa5xa6xa7xa8xa9xaaxb2xb3xb4xb5xb6xb7xb8xb9xbaxc2xc3xc4xc5xc6xc7xc8xc9xcaxd2xd3xd4xd5xd6xd7xd8xd9xdaxe1xe2xe3xe4xe5xe6xe7xe8xe9xeaxf1xf2xf3xf4xf5xf6xf7xf8xf9xfaxffxc4x00x1fx01x00x03x01x01x01x01x01x01x01x01x01x00x00x00x00x00x00x01x02x03x04x05x06x07x08tnx0bxffxc4x00xb5x11x00x02x01x02x04x04x03x04x07x05x04x04x00x01x02wx00x01x02x03x11x04x05!1x06x12AQx07aqx13"2x81x08x14Bx91xa1xb1xc1t#3Rxf0x15brxd1nx16$4xe1%xf1x17x18x19x1a&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzx82x83x84x85x86x87x88x89x8ax92x93x94x95x96x97x98x99x9axa2xa3xa4xa5xa6xa7xa8xa9xaaxb2xb3xb4xb5xb6xb7xb8xb9xbaxc2xc3xc4xc5xc6xc7xc8xc9xcaxd2xd3xd4xd5xd6xd7xd8xd9xdaxe2xe3xe4xe5xe6xe7xe8xe9xeaxf2xf3xf4xf5xf6xf7xf8xf9xfaxffxdax00x0cx03x01x00x02x11x03x11x00?x00xf7xfa(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80n(xa2x80x10x1cx80hxa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00(xa2x8ax00xffxd9'

However, when I try to convert it into a base64 string and into an image using this code snippet

var img = document.createElement('img');
    img.src = 'data:image/jpeg;base64,' + btoa('(data goes here)');
    document.body.appendChild(img);

it doesn’t generate a valid image – just the missing image icon.

I’ve also tried creating an image element in the HTML file itself and then modifying its src using JS, but that also didn’t work.

Is there anything wrong with the data itself, or can I do something to generate the image using JS?

(For extra context, I got the binary data for this image by getting a user’s profile picture using the Microsoft Graph API.)

How to remove quotes from the date in array

In js, I am getting the results as given below.

 var dates = ['2023-02-24', '2023-02-25', '2023-02-26', '2023-02-27', '2023-02-28']

But in my high chart, it is expecting the dates given below.

 var dates = [2023-02-24, 2023-02-25,2023-02-26,2023-02-27,2023-02-28]

Can anyone please help me with how can i convert this please suggest some solution it will really help.

Shipping Address does not automatically go in the PlaceOrder page

the current situation is showing this, the shipping in order info should be showing the country and the address in the deliver to showing be showing the address of the customer. but it’s showing the image below

1

when I refresh the page, now the page is showing what it should be showing, the country and the address is there, like the image below

2

how do I make it that I don’t have to reload the page to show the country and the address of the customer?

this is the code of order info

<div className="col-md-8 center">
    <h5>
        <strong>Order info</strong>
    </h5>
    <p>Shipping: {cart.shippingAddress.country}</p>
    <p>Pay method: {cart.paymentMethod}</p>
</div>

this is the code of deliver to

<div className="col-md-8 center">
    <h5>
        <strong>Deliver to</strong>
    </h5>
    <p>
        Address: {cart.shippingAddress.address},{' '}
        {cart.shippingAddress.city},
        {cart.shippingAddress.province},{' '}
        {cart.shippingAddress.postalCode}
    </p>
</div>

also in redux, i’ve noticed that there are two shippingAddress
enter image description here

Is There a Way to Hide Builtin Network Error?

I’m using node.js to run my discord music bot, oops that’s not the point…

The point is that I’m using soundcloud-downloader to download music, which uses axios I guess.

Whenever I type in a invalid url, its errors flood my entire console!

What I want is:
If the website does not exist, just print “Invalid URL!”, don’t print any details.

P.S. According to the information on the Internet, catch is useless…

The error I got:

(Even breaks stack overflow character limits...)

          onkeylog: [Function: onkeylog],
          onhandshakestart: {},
          onhandshakedone: [Function (anonymous)],
          onocspresponse: [Function: onocspresponse],
          onnewsession: [Function: onnewsessionclient],
          onerror: [Function: onerror],
          [Symbol(owner_symbol)]: [Circular *1]
        },
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular *2],
        [Symbol(res)]: TLSWrap {
          _parent: TCP {
            reading: [Getter/Setter],
            onconnection: null,
            [Symbol(owner_symbol)]: [Circular *1]
          },
          _parentWrap: undefined,
          _secureContext: SecureContext { context: SecureContext {} },
          reading: true,
          onkeylog: [Function: onkeylog],
          onhandshakestart: {},
          onhandshakedone: [Function (anonymous)],
          onocspresponse: [Function: onocspresponse],
          onnewsession: [Function: onnewsessionclient],
          onerror: [Function: onerror],
          [Symbol(owner_symbol)]: [Circular *1]
        },
        [Symbol(verified)]: true,
        [Symbol(pendingSession)]: null,
        [Symbol(async_id_symbol)]: 315,
        [Symbol(kHandle)]: TLSWrap {
          _parent: TCP {
            reading: [Getter/Setter],
            onconnection: null,
            [Symbol(owner_symbol)]: [Circular *1]
          },
          _parentWrap: undefined,
          _secureContext: SecureContext { context: SecureContext {} },
          reading: true,
          onkeylog: [Function: onkeylog],
          onhandshakestart: {},
          onhandshakedone: [Function (anonymous)],
          onocspresponse: [Function: onocspresponse],
          onnewsession: [Function: onnewsessionclient],
          onerror: [Function: onerror],
          [Symbol(owner_symbol)]: [Circular *1]
        },
        [Symbol(lastWriteQueueSize)]: 0,
        [Symbol(timeout)]: null,
        [Symbol(kBuffer)]: null,
        [Symbol(kBufferCb)]: null,
        [Symbol(kBufferGen)]: null,
        [Symbol(kCapture)]: false,
        [Symbol(kSetNoDelay)]: false,
        [Symbol(kSetKeepAlive)]: false,
        [Symbol(kSetKeepAliveInitialDelay)]: 0,
        [Symbol(kBytesRead)]: 0,
        [Symbol(kBytesWritten)]: 0,
        [Symbol(connect-options)]: {
          rejectUnauthorized: true,
          ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
          checkServerIdentity: [Function: checkServerIdentity],
          minDHSize: 1024,
          maxRedirects: 21,
          maxBodyLength: 10485760,
          protocol: 'https:',
          path: null,
          method: 'GET',
          headers: {
            Accept: 'application/json, text/plain, */*',
            'User-Agent': 'axios/0.21.4'
          },
          agent: undefined,
          agents: { http: undefined, https: undefined },
          auth: undefined,
          hostname: 'api-v2.soundcloud.com',
          port: 443,
          nativeProtocols: { 'http:': [Object], 'https:': [Object] },
          pathname: '/resolve',
          search: '?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY', 
          _defaultAgent: Agent {
            _events: [Object: null prototype],
            _eventsCount: 2,
            _maxListeners: undefined,
            defaultPort: 443,
            protocol: 'https:',
            options: [Object: null prototype],
            requests: [Object: null prototype] {},
            sockets: [Object: null prototype],
            freeSockets: [Object: null prototype] {},
            keepAliveMsecs: 1000,
            keepAlive: false,
            maxSockets: Infinity,
            maxFreeSockets: 256,
            scheduling: 'lifo',
            maxTotalSockets: Infinity,
            totalSocketCount: 1,
            maxCachedSessions: 100,
            _sessionCache: [Object],
            [Symbol(kCapture)]: false
          },
          host: 'api-v2.soundcloud.com',
          noDelay: true,
          servername: 'api-v2.soundcloud.com',
          _agentKey: 'api-v2.soundcloud.com:443:::::::::::::::::::::',
          encoding: null,
          singleUse: true
        }
      },
      _header: 'GET /resolve?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY HTTP/1.1rn' +
        'Accept: application/json, text/plain, */*rn' +
        'User-Agent: axios/0.21.4rn' +
        'Host: api-v2.soundcloud.comrn' +
        'Connection: closern' +
        'rn',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: Agent {
        _events: [Object: null prototype] {
          free: [Function (anonymous)],
          newListener: [Function: maybeEnableKeylog]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object: null prototype] { noDelay: true, path: null },
        requests: [Object: null prototype] {},
        sockets: [Object: null prototype] {
          'api-v2.soundcloud.com:443:::::::::::::::::::::': [ [TLSSocket] ]
        },
        freeSockets: [Object: null prototype] {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        scheduling: 'lifo',
        maxTotalSockets: Infinity,
        totalSocketCount: 1,
        maxCachedSessions: 100,
        _sessionCache: {
          map: {
            'soundcloud.com:443:::::::::::::::::::::': [Buffer [Uint8Array]],
            'a-v2.sndcdn.com:443:::::::::::::::::::::': [Buffer [Uint8Array]],
            'api-v2.soundcloud.com:443:::::::::::::::::::::': [Buffer [Uint8Array]]
          },
          list: [
            'soundcloud.com:443:::::::::::::::::::::',
            'a-v2.sndcdn.com:443:::::::::::::::::::::',
            'api-v2.soundcloud.com:443:::::::::::::::::::::'
          ]
        },
        [Symbol(kCapture)]: false
      },
      socketPath: undefined,
      method: 'GET',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      path: '/resolve?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY',
      _ended: true,
      res: IncomingMessage {
        _readableState: ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: BufferList { head: null, tail: null, length: 0 },
          length: 0,
          pipes: [],
          flowing: true,
          ended: true,
          endEmitted: true,
          reading: false,
          constructed: true,
          sync: true,
          needReadable: false,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          errorEmitted: false,
          emitClose: true,
          autoDestroy: true,
          destroyed: true,
          errored: null,
          closed: true,
          closeEmitted: true,
          defaultEncoding: 'utf8',
          awaitDrainWriters: null,
          multiAwaitDrain: false,
          readingMore: true,
          dataEmitted: true,
          decoder: null,
          encoding: null,
          [Symbol(kPaused)]: false
        },
        _events: [Object: null prototype] {
          end: [ [Function: responseOnEnd], [Function: handleStreamEnd] ],
          data: [Function: handleStreamData],
          error: [Function: handleStreamError]
        },
        _eventsCount: 3,
        _maxListeners: undefined,
        socket: <ref *1> TLSSocket {
          _tlsOptions: {
            allowHalfOpen: undefined,
            pipe: false,
            secureContext: [SecureContext],
            isServer: false,
            requestCert: true,
            rejectUnauthorized: true,
            session: undefined,
            ALPNProtocols: undefined,
            requestOCSP: undefined,
            enableTrace: undefined,
            pskCallback: undefined,
            highWaterMark: undefined,
            onread: undefined,
            signal: undefined
          },
          _secureEstablished: true,
          _securePending: false,
          _newSessionPending: false,
          _controlReleased: true,
          secureConnecting: false,
          _SNICallback: null,
          servername: 'api-v2.soundcloud.com',
          alpnProtocol: false,
          authorized: true,
          authorizationError: null,
          encrypted: true,
          _events: [Object: null prototype] {
            close: [Array],
            end: [Function: onReadableStreamEnd],
            newListener: [Function: keylogNewListener],
            secure: [Function: onConnectSecure],
            session: [Function (anonymous)],
            free: [Function: onFree],
            timeout: [Function: onTimeout],
            agentRemove: [Function: onRemove],
            error: [Function: socketErrorListener],
            finish: [Function]
          },
          _eventsCount: 10,
          connecting: false,
          _hadError: false,
          _parent: null,
          _host: 'api-v2.soundcloud.com',
          _closeAfterHandlingError: false,
          _readableState: ReadableState {
            objectMode: false,
            highWaterMark: 16384,
            buffer: [BufferList],
            length: 0,
            pipes: [],
            flowing: true,
            ended: false,
            endEmitted: false,
            reading: true,
            constructed: true,
            sync: false,
            needReadable: true,
            emittedReadable: false,
            readableListening: false,
            resumeScheduled: false,
            errorEmitted: false,
            emitClose: false,
            autoDestroy: true,
            destroyed: false,
            errored: null,
            closed: false,
            closeEmitted: false,
            defaultEncoding: 'utf8',
            awaitDrainWriters: null,
            multiAwaitDrain: false,
            readingMore: false,
            dataEmitted: true,
            decoder: null,
            encoding: null,
            [Symbol(kPaused)]: false
          },
          _maxListeners: undefined,
          _writableState: WritableState {
            objectMode: false,
            highWaterMark: 16384,
            finalCalled: true,
            needDrain: false,
            ending: true,
            ended: true,
            finished: false,
            destroyed: false,
            decodeStrings: false,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: false,
            bufferProcessing: false,
            onwrite: [Function: bound onwrite],
            writecb: null,
            writelen: 0,
            afterWriteTickInfo: null,
            buffered: [],
            bufferedIndex: 0,
            allBuffers: true,
            allNoop: true,
            pendingcb: 1,
            constructed: true,
            prefinished: false,
            errorEmitted: false,
            emitClose: false,
            autoDestroy: true,
            errored: null,
            closed: false,
            closeEmitted: false,
            [Symbol(kOnFinished)]: []
          },
          allowHalfOpen: false,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: undefined,
          _server: null,
          ssl: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          _requestCert: true,
          _rejectUnauthorized: true,
          parser: null,
          _httpMessage: [Circular *2],
          [Symbol(res)]: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(verified)]: true,
          [Symbol(pendingSession)]: null,
          [Symbol(async_id_symbol)]: 315,
          [Symbol(kHandle)]: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: null,
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kSetNoDelay)]: false,
          [Symbol(kSetKeepAlive)]: false,
          [Symbol(kSetKeepAliveInitialDelay)]: 0,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(connect-options)]: {
            rejectUnauthorized: true,
            ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
            checkServerIdentity: [Function: checkServerIdentity],
            minDHSize: 1024,
            maxRedirects: 21,
            maxBodyLength: 10485760,
            protocol: 'https:',
            path: null,
            method: 'GET',
            headers: [Object],
            agent: undefined,
            agents: [Object],
            auth: undefined,
            hostname: 'api-v2.soundcloud.com',
            port: 443,
            nativeProtocols: [Object],
            pathname: '/resolve',
            search: '?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY',
            _defaultAgent: [Agent],
            host: 'api-v2.soundcloud.com',
            noDelay: true,
            servername: 'api-v2.soundcloud.com',
            _agentKey: 'api-v2.soundcloud.com:443:::::::::::::::::::::',
            encoding: null,
            singleUse: true
          }
        },
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        rawHeaders: [
          'Content-Type',
          'application/json; charset=utf-8',
          'Content-Length',
          '2',
          'Connection',
          'close',
          'Date',
          'Sun, 26 Mar 2023 09:27:14 GMT',
          'x-robots-tag',
          'noindex',
          'Cache-Control',
          'private, max-age=0',
          'referrer-policy',
          'no-referrer',
          'x-frame-options',
          'DENY',
          'x-content-type-options',
          'nosniff',
          'strict-transport-security',
          'max-age=63072000',
          'Server',
          'am/2',
          'Vary',
          'Origin',
          'X-Cache',
          'Error from cloudfront',
          'Via',
          '1.1 a55d34628b043ad0c3a5f728ad027e04.cloudfront.net (CloudFront)',
          'X-Amz-Cf-Pop',
          'TPE51-C1',
          'X-Amz-Cf-Id',
          'NZVD4xlV8MV3Ofdr040yjttQDV5xPXit0RAmUU1kZUh-w9AbH6DlBQ=='
        ],
        rawTrailers: [],
        aborted: false,
        upgrade: false,
        url: '',
        method: null,
        statusCode: 404,
        statusMessage: 'Not Found',
        client: <ref *1> TLSSocket {
          _tlsOptions: {
            allowHalfOpen: undefined,
            pipe: false,
            secureContext: [SecureContext],
            isServer: false,
            requestCert: true,
            rejectUnauthorized: true,
            session: undefined,
            ALPNProtocols: undefined,
            requestOCSP: undefined,
            enableTrace: undefined,
            pskCallback: undefined,
            highWaterMark: undefined,
            onread: undefined,
            signal: undefined
          },
          _secureEstablished: true,
          _securePending: false,
          _newSessionPending: false,
          _controlReleased: true,
          secureConnecting: false,
          _SNICallback: null,
          servername: 'api-v2.soundcloud.com',
          alpnProtocol: false,
          authorized: true,
          authorizationError: null,
          encrypted: true,
          _events: [Object: null prototype] {
            close: [Array],
            end: [Function: onReadableStreamEnd],
            newListener: [Function: keylogNewListener],
            secure: [Function: onConnectSecure],
            session: [Function (anonymous)],
            free: [Function: onFree],
            timeout: [Function: onTimeout],
            agentRemove: [Function: onRemove],
            error: [Function: socketErrorListener],
            finish: [Function]
          },
          _eventsCount: 10,
          connecting: false,
          _hadError: false,
          _parent: null,
          _host: 'api-v2.soundcloud.com',
          _closeAfterHandlingError: false,
          _readableState: ReadableState {
            objectMode: false,
            highWaterMark: 16384,
            buffer: [BufferList],
            length: 0,
            pipes: [],
            flowing: true,
            ended: false,
            endEmitted: false,
            reading: true,
            constructed: true,
            sync: false,
            needReadable: true,
            emittedReadable: false,
            readableListening: false,
            resumeScheduled: false,
            errorEmitted: false,
            emitClose: false,
            autoDestroy: true,
            destroyed: false,
            errored: null,
            closed: false,
            closeEmitted: false,
            defaultEncoding: 'utf8',
            awaitDrainWriters: null,
            multiAwaitDrain: false,
            readingMore: false,
            dataEmitted: true,
            decoder: null,
            encoding: null,
            [Symbol(kPaused)]: false
          },
          _maxListeners: undefined,
          _writableState: WritableState {
            objectMode: false,
            highWaterMark: 16384,
            finalCalled: true,
            needDrain: false,
            ending: true,
            ended: true,
            finished: false,
            destroyed: false,
            decodeStrings: false,
            defaultEncoding: 'utf8',
            length: 0,
            writing: false,
            corked: 0,
            sync: false,
            bufferProcessing: false,
            onwrite: [Function: bound onwrite],
            writecb: null,
            writelen: 0,
            afterWriteTickInfo: null,
            buffered: [],
            bufferedIndex: 0,
            allBuffers: true,
            allNoop: true,
            pendingcb: 1,
            constructed: true,
            prefinished: false,
            errorEmitted: false,
            emitClose: false,
            autoDestroy: true,
            errored: null,
            closed: false,
            closeEmitted: false,
            [Symbol(kOnFinished)]: []
          },
          allowHalfOpen: false,
          _sockname: null,
          _pendingData: null,
          _pendingEncoding: '',
          server: undefined,
          _server: null,
          ssl: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          _requestCert: true,
          _rejectUnauthorized: true,
          parser: null,
          _httpMessage: [Circular *2],
          [Symbol(res)]: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(verified)]: true,
          [Symbol(pendingSession)]: null,
          [Symbol(async_id_symbol)]: 315,
          [Symbol(kHandle)]: TLSWrap {
            _parent: [TCP],
            _parentWrap: undefined,
            _secureContext: [SecureContext],
            reading: true,
            onkeylog: [Function: onkeylog],
            onhandshakestart: {},
            onhandshakedone: [Function (anonymous)],
            onocspresponse: [Function: onocspresponse],
            onnewsession: [Function: onnewsessionclient],
            onerror: [Function: onerror],
            [Symbol(owner_symbol)]: [Circular *1]
          },
          [Symbol(lastWriteQueueSize)]: 0,
          [Symbol(timeout)]: null,
          [Symbol(kBuffer)]: null,
          [Symbol(kBufferCb)]: null,
          [Symbol(kBufferGen)]: null,
          [Symbol(kCapture)]: false,
          [Symbol(kSetNoDelay)]: false,
          [Symbol(kSetKeepAlive)]: false,
          [Symbol(kSetKeepAliveInitialDelay)]: 0,
          [Symbol(kBytesRead)]: 0,
          [Symbol(kBytesWritten)]: 0,
          [Symbol(connect-options)]: {
            rejectUnauthorized: true,
            ciphers: 'TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA',
            checkServerIdentity: [Function: checkServerIdentity],
            minDHSize: 1024,
            maxRedirects: 21,
            maxBodyLength: 10485760,
            protocol: 'https:',
            path: null,
            method: 'GET',
            headers: [Object],
            agent: undefined,
            agents: [Object],
            auth: undefined,
            hostname: 'api-v2.soundcloud.com',
            port: 443,
            nativeProtocols: [Object],
            pathname: '/resolve',
            search: '?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY',
            _defaultAgent: [Agent],
            host: 'api-v2.soundcloud.com',
            noDelay: true,
            servername: 'api-v2.soundcloud.com',
            _agentKey: 'api-v2.soundcloud.com:443:::::::::::::::::::::',
            encoding: null,
            singleUse: true
          }
        },
        _consuming: false,
        _dumped: false,
        req: [Circular *2],
        responseUrl: 'https://api-v2.soundcloud.com/resolve?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY',
        redirects: [],
        [Symbol(kCapture)]: false,
        [Symbol(kHeaders)]: {
          'content-type': 'application/json; charset=utf-8',
          'content-length': '2',
          connection: 'close',
          date: 'Sun, 26 Mar 2023 09:27:14 GMT',
          'x-robots-tag': 'noindex',
          'cache-control': 'private, max-age=0',
          'referrer-policy': 'no-referrer',
          'x-frame-options': 'DENY',
          'x-content-type-options': 'nosniff',
          'strict-transport-security': 'max-age=63072000',
          server: 'am/2',
          vary: 'Origin',
          'x-cache': 'Error from cloudfront',
          via: '1.1 a55d34628b043ad0c3a5f728ad027e04.cloudfront.net (CloudFront)',
          'x-amz-cf-pop': 'TPE51-C1',
          'x-amz-cf-id': 'NZVD4xlV8MV3Ofdr040yjttQDV5xPXit0RAmUU1kZUh-w9AbH6DlBQ=='
        },
        [Symbol(kHeadersCount)]: 32,
        [Symbol(kTrailers)]: null,
        [Symbol(kTrailersCount)]: 0
      },
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'api-v2.soundcloud.com',
      protocol: 'https:',
      _redirectable: Writable {
        _writableState: WritableState {
          objectMode: false,
          highWaterMark: 16384,
          finalCalled: false,
          needDrain: false,
          ending: false,
          ended: false,
          finished: false,
          destroyed: false,
          decodeStrings: true,
          defaultEncoding: 'utf8',
          length: 0,
          writing: false,
          corked: 0,
          sync: true,
          bufferProcessing: false,
          onwrite: [Function: bound onwrite],
          writecb: null,
          writelen: 0,
          afterWriteTickInfo: null,
          buffered: [],
          bufferedIndex: 0,
          allBuffers: true,
          allNoop: true,
          pendingcb: 0,
          constructed: true,
          prefinished: false,
          errorEmitted: false,
          emitClose: true,
          autoDestroy: true,
          errored: null,
          closed: false,
          closeEmitted: false,
          [Symbol(kOnFinished)]: []
        },
        _events: [Object: null prototype] {
          response: [Function: handleResponse],
          error: [Function: handleRequestError]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        _options: {
          maxRedirects: 21,
          maxBodyLength: 10485760,
          protocol: 'https:',
          path: '/resolve?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY',
          method: 'GET',
          headers: {
            Accept: 'application/json, text/plain, */*',
            'User-Agent': 'axios/0.21.4'
          },
          agent: undefined,
          agents: { http: undefined, https: undefined },
          auth: undefined,
          hostname: 'api-v2.soundcloud.com',
          port: null,
          nativeProtocols: { 'http:': [Object], 'https:': [Object] },
          pathname: '/resolve',
          search: '?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY'  
        },
        _ended: true,
        _ending: true,
        _redirectCount: 0,
        _redirects: [],
        _requestBodyLength: 0,
        _requestBodyBuffers: [],
        _onNativeResponse: [Function (anonymous)],
        _currentRequest: [Circular *2],
        _currentUrl: 'https://api-v2.soundcloud.com/resolve?url=https%3A%2F%2Fsoundcloud.com%2F12345%2F67890&client_id=RMDIzNoU4QIzQsT3xq9J5TdxFFQlJvLY',
        [Symbol(kCapture)]: false
      },
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kEndCalled)]: true,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype] {
        accept: [ 'Accept', 'application/json, text/plain, */*' ],
        'user-agent': [ 'User-Agent', 'axios/0.21.4' ],
        host: [ 'Host', 'api-v2.soundcloud.com' ]
      },
      [Symbol(kUniqueHeaders)]: null
    },
    data: {}
  },
  isAxiosError: true,
  toJSON: [Function: toJSON]
}

Javascript: how can global functions use data dynamically obtained from readFileData

I have the following code (simplified from a more elaborate code):

HTML:

<form>
  <input id="newfile" accept='text/plain' type="file" onchange="readFileData(event)" />
</form>
...
<p id="description"></p>

Javascript

var setname = '';
function readFileData(event) {
  file = event.target.files[0];
  setname = file.name.split('.')[0];
  var reader = new FileReader();

  reader.onload = function(e) {
    dictionary = toDict(e.target.result);
  }
  reader.readAsText(file);
}
desc = document.getElementById('description');

desc.innerHTML = setname
function useDictionary(dictionary) {
  // more code here
}

Notes:

  1. the function useDictionary() is going to be used by another HTML element’s onkeyup function, so maybe it has to be accessible from the global level, I’m not so sure.
  2. the files being accessed are only local in relation to the html file, and this is a single html file.
  3. I am using vanilla javascript, no preprocessors or libraries, and I want to keep it that way.

My main questions, however, are these. How can I make desc.innerHTML access the variable setname? How can I make the function useDictionary() access the variable dictionary?

I have tried inserting useDictionary() within the reader.onload block, but it doesn’t work either.

Problem creating an eml file with an attachment in react. The attachment file opens empty in Outlook

I’m creating an eml file on my website with an attachment.
I saw in this link: eml with attachment to do it in the following way, but while downloading the eml file it opens with an attachment. When I click the attachment the attachment just opens empty even though its size is more than 0 bytes.

  const makeOutlookFile = () => {
        const text = ` To: Demo-Recipient <[email protected]>

Subject: EML with attachments

X-Unsent: 1

Content-Type: multipart/mixed; boundary=boundary_text_string

 

--boundary_text_string

Content-Type: text/html; charset=UTF-8

 

<html>

<body>

<p>Example</p>

</body>

</html>

 

--boundary_text_string

Content-Type: application/octet-stream; name=demo.log

Content-Transfer-Encoding: base64

Content-Disposition: attachment; filename="demo.log"

aGVsbG8gd29ybGQ=

--boundary_text_string--`;

        let textFile = null;

        var data = new Blob([text], { type: 'message/rfc822' });

        textFile = window.URL.createObjectURL(data);


        let link = document.createElement("a");

        link.href = textFile;

        link.target = "_blank";

        link.download = "";

        document.body.appendChild(link);

        link.click();

        link.remove();

    };

This is how it open: enter image description here

I searched a lot about how to create an eml file with an attachment but all the answers give this code more or less

How can I show the legend in my PieChart?

so I’m trying to show the name of the colors in my PieChart, so what I’m trying to get here is the name and put it as a legend, enter image description here

Json

    {
        "choice": "20-29 yrs. old",
        "count": 4
    },
    {
        "choice": "30-39 yrs. old",
        "count": 2
    },
    {
        "choice": "40-49 yrs. old",
        "count": 1
    },
    {
        "choice": "50-59 yrs. old",
        "count": 2
    },
    {
        "choice": "60 yrs. old and above",
        "count": 1
    }.

This is how I render the PieChart.

 <ResponsiveContainer width="100%" height={400}>
    <PieChart>
      <Pie
        data={data}
        cx="50%"
        cy="50%"
        labelLine={false}
        label={renderCustomizedLabel}
        outerRadius={150}
        fill="#8884d8"
        dataKey="count"
      >
        {data.map((entry, index) => (
          <Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
        ))}
      </Pie>
      <Legend verticalAlign="bottom" />
    </PieChart>
    
  </ResponsiveContainer>