Can’t publish to npm

I do npm publish and goes through all the checks but then it returns the following

48 error code E403
49 error 403 403 Forbidden - PUT https://registry.npmjs.com/tictactoe - You do not have permission to publish "tictactoe". Are you logged in as the correct user?
50 error 403 In most cases, you or one of your dependencies are requesting
50 error 403 a package version that is forbidden by your security policy, or
50 error 403 on a server you do not have access to.

So at first I do npm whoami and it returns makashi my username, So I know im logged in.

And my dependencies seem to fine, I am able to import them and import the package and run it fine.

{
    "name": "tictactoe",
    "version": "1.0.0",
    "description": "Simple Tic Tac Toe module to play with ease!",
    "main": "index.js",
    "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
    },
    "repository": {
        "type": "git",
        "url": "github.com/MakashiDev/tictactoe"
    },
    "keywords": [
        "tictactoe",
        "game",
        "fun"
    ],
    "author": "makashi",
    "license": "MIT",
    "dependencies": {
        "prompt-sync": "^4.2.0"
    }
}

There is my package.json everything seems normal and I cant find anything incorrect. I am very confused on this so please help figure this out.

Thanks
-Makashi

The inner arrays in an AoA seem to hold onto their references through multiple copy functions. WTF JS?

I am passing a Array of Arrays (2d array) to a function that not only makes a copy original along with my attempts to copy from the original outside of the function, but the references hold.

Have been assuming it has something to do with the fact that the inner arrays are never explicitly “removed” from reference, but if it’s a stupid typo, I apologize.

-made an AoA > dat
-copied it to > cpy
-passed to a function that edits the elements of a copy of cpy.
-dat is somehow affected
-wtf?

// may cause headache.
const copy = arr => [...(arr.slice())].slice();
const spiral = (grid, start = [0, 0]) => {
   if (!Array.isArray(grid) || !Array.isArray(grid[0]) || grid.length < 2 || grid[0].length < 2) return grid;
   let dir = [
         [0, 1],
         [1, 0],
         [0, -1],
         [-1, 0]
      ],
      corners = [
         [0, grid[0].length - 1],
         [grid.length - 1, grid[0].length - 1],
         [grid.length - 1, 0],
         [1, 0]
      ],
      size = grid.length * grid[0].length,
      indx = 0,
      stepi = 0,
      step = dir[stepi],
      result = copy(grid),   //  <------+
      [r, c] = start;        //         |-----------{ the two culprit lines perhaps? 
   while (size--) {          //         |           { the rows are probably making it 
      result[r][c] = indx++; //  <------+           { through by reference.
      if (r === corners[stepi][0] && c === corners[stepi][1]) {
         if (stepi === 3) 
           corners = corners.map((e, i) => 
             [e[0] + [1, -1, -1, 1][i], e[1] + [-1, -1, 1, 1][i]]);
         stepi = (stepi + 1) % 4;
         step = dir[stepi];
      }
      r = r + step[0];
      c = c + step[1];
   }
   return result;
}
// can't seperate this 2d array from the reference for some reason. 
//suspect it's because of the inner arrays, but still seems rediculous.
const dat = Array.from(new Array(5),
   (_, i) => Array.from(new Array(5),
      (__, j) => 5 * i + j));
console.log('array dat is correct here.');
console.log(dat);
// this nasty peice of work is just an attempt to divorce from original array. 
let val = [...copy([...dat].slice().reduce((a, c) => [...a, c], []))];
let cpy = spiral(val);
console.log('cpy is completely modified')
console.log(cpy);
console.log('only copies of dat have made it all the way to cpy, right?')
console.log(dat);
console.log('nyooope. what the actual piss? are the inner arrays being fed straight through by reference?');

/* ================================output=================================================

array dat is correct here.
dat = [
   [0, 1, 2, 3, 4],
   [5, 6, 7, 8, 9],
   [10, 11, 12, 13, 14],
   [15, 16, 17, 18, 19],
   [20, 21, 22, 23, 24]
]
only copies of dat have made it all the way to ref, right ? 
cpy = [
      [0, 1, 2, 3, 4],
      [15, 16, 17, 18, 5],
      [14, 23, 24, 19, 6],
      [13, 22, 21, 20, 7],
      [12, 11, 10, 9, 8]
   ]
nyooope.what the actual piss ? are the inner arrays being fed straight through by reference ?
dat = [
   [0, 1, 2, 3, 4],
   [15, 16, 17, 18, 5],
   [14, 23, 24, 19, 6],
   [13, 22, 21, 20, 7],
   [12, 11, 10, 9, 8]
]
*/

WAMP server local host is not allowing JavaScript code to be functional [duplicate]

I am sorry in advance if this question is confusing but I am very new to web design

So I’ve downloaded WAMP server in order to build a website and so far I have had a lot success with creating .php and .css files to interact with the MySQL database I have created. However when I try adding JavaScript code to my php files nothing new happens when I open those files in the browser using http://localhost/myFile.php

I have an example here of trying to completely rewrite the text box that appears when my form input is an invalid pattern

php

<!DOCTYPE html> 
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <script type="text/javascript" src="testJS.js"></script>
    <title>Search</title>
</head>
<body>
    <header>Enter Quote Number</header>
    <form action="qSearchResults.php" method="post" >
        <input type="text" name="salesman" id="salesman" maxlength="2" minlength="2" placeholder="01" required="" pattern="[0-9]{2}"/>
        -
        <input type="text" name="year" id="year" maxlength="2" minlenght="2" placeholder="00" required="" pattern="[0-9]{2}"/>
        <input type="text" name="number" id="number" maxlength="4" minlength="4" placeholder="0002" required="" pattern="[0-9]{4}"/>
        <input type="text" name="revision" maxlength="1" placeholder="A" pattern="[A-Za-z]"/>
        <input type="submit" value="Search" 
        onclick="this.form.target='_blank';return true;"/>
    </form>
    
</body>
</html>

JS

var salesmanInput = document.getElementById('salesman');
    salesmanInput.oninvalid = function(event){
        event.target.setCustomValidity('Salesman number should be a two digit number, even if the first digit is 0');
    }

at this point I’m not sure if the problem is my JavaScript code itself, a configuration I need to change with wamp server or a lack of understanding on my part as to how php being server side and JS being client side allows them to interact on my localhost

Any help here would be greatly appreciated, and I will be more than happy to provide whatever else y’all might need in order to help me solve this

Take input from form, add it into a URL

beginner here i’ve recently gotten into making websites and have ran into some issues.
My goal right now it to be able to grab a minecraft username from a form, convert the name into a UUID and then mess with that later.

For now, im stuck on a little part. Here’s the API im using for reference:
https://mojang-api-docs.netlify.app/no-auth/uuid-to-profile.html
this is where you can find the information
https://api.mojang.com/users/profiles/minecraft/:username
for example, https://api.mojang.com/users/profiles/minecraft/xJEMAx

Now, i’ve made this in my html tab for signing in (signin.html)

<div class="box-container">
        <div class="header">Enter your minecraft username here!</div>
        <div class="content">
            <form onsubmit="changeFormAction()">
                    <input type="text" name="ign" autocorrect="off" autocapitalize="off" spellcheck="false">
                    <input type="submit" value="Sign in">
            </form>
        </div>
    </div>
    </div>

And this is the function: (separate place, transform.js)

```function changeFormAction() {
  var item = document.getElementByName("ign").value;
  var form = username;
  form.action = "https://api.mojang.com/users/profiles/minecraft/" + username;
  form.submit();
}

And so now i need to find a way to substitue the input from this form into the link. It does not seem to work though.

my app is unable to find the css and js file in rails assets

ActionController::RoutingError (No route matches [GET] “/styles/responsive.css”):

ActionController::RoutingError (No route matches [GET] “/assets/plugins/OwlCarousel2-2.2.1/owl.carousel.css”):

ActionController::RoutingError (No route matches [GET] “/assets/plugins/OwlCarousel2-2.2.1/animate.css”):

ActionController::RoutingError (No route matches [GET] “/assets/plugins/OwlCarousel2-2.2.1/owl.theme.default.css”):

ActionController::RoutingError (No route matches [GET] “/assets/plugins/fontawesome-free-5.0.1/css/fontawesome-all.css”):

ActionController::RoutingError (No route matches [GET] “/assets/images/exam.svg”):

Mapping to React Modal renders all items from array instead of mapping by their ID

My issue is that when I map the data into the Modal, it is returning all items from that field in the array e.g. mapping Business Name will return all business names in the array instead of 1.

I am also using React-Bootstrap-Table-Next in the same component to render data. A button is added to each row of the table which I would like to click and bring up more information on that particular row.

Button being rendered in the table with onClick handler to open the modal:

const columns = [
        { dataField: "View", text: "View", 
        formatter: () => {return <Button variant="success" onClick={handleShow}>View</Button>},
        headerStyle: () => {return { width: "5%" };} },
        { dataField: "BusinessName", text: "Business Name", headerStyle: () => {return { width: "27%" };} },
    ];

Modal state handling:

    const [showModal, setShow] = useState(false);
    const handleClose = () => setShow(false);
    const handleShow = () => setShow(true);

Modal code with map function:

<Modal 
            show={showModal} 
            onHide={handleClose}
            size="lg" 
            centered
        >
            <Modal.Header closeButton>
                {submitted.map((item) => 
                <Modal.Title key={item.Id}> {item.BusinessName}</Modal.Title>
                )}  
            </Modal.Header>
            <Modal.Body></Modal.Body>
            <Modal.Footer>
                <Button variant="secondary" onClick={handleClose}>
                    Close
                </Button>
                <Button variant="primary" onClick={handleClose}>
                    Save Changes
                </Button>
            </Modal.Footer>
        </Modal>

Getting and setting the data:

const [submitted, setSubmitted] = useState([]);


const getSubmittedData = async () => {
        try {
            const response = await Axios.get(url);
            setSubmitted(response.data);
            console.log(response.data);
            setLoading(true);
        } catch (e) {
            console.log(e)
        }
    };

Why Do I Have “joinAdInterestGroup” Scriplets and Tracing in My Console After Installing React-Scripts as a DevDependency?

I reinstalled “react-scripts” (5.0.1) as a devDependency to get around the npm audit false-alarm issue that flags one of its dependencies as a severe vulnerability. Starting after that (as far as I can tell) not only do I get multiple “navigator.joinAdInterestGroup” and navigator.leaveAdInterestGroup” scriplets with tracing running in my console every time I boot up my frontend (see below), but there are also mentions of a “coupang.com” and “coupangcdn.com.” What is this, and how can I get rid of it? Thanks.

VM6:206 #%#//scriptlet("set-constant", "navigator.joinAdInterestGroup", "undefined") trace start

VM6:208 console.trace
hit @ VM6:208

VM6:210 #%#//scriptlet("set-constant", "navigator.joinAdInterestGroup", "undefined") trace end

VM6:502 #%#//scriptlet("set-constant", "navigator.leaveAdInterestGroup", "undefined") trace start

VM6:504 console.trace
hit @ VM6:504

VM6:506 #%#//scriptlet("set-constant", "navigator.leaveAdInterestGroup", "undefined") trace end

VM6:798 #%#//scriptlet("set-constant", "navigator.runAdAuction", "undefined") trace start

VM6:800 console.trace
hit @ VM6:800

VM6:802 #%#//scriptlet("set-constant", "navigator.runAdAuction", "undefined") trace end

VM6:1094 #%#//scriptlet("set-constant", "navigator.adAuctionComponents", "undefined") trace start

VM6:1096 console.trace
hit @ VM6:1096

VM6:1098 #%#//scriptlet("set-constant", "navigator.adAuctionComponents", "undefined") trace end

VM6:1390 #%#//scriptlet("set-constant", "Document.prototype.browsingTopics", "undefined") trace start

VM6:1392 console.trace
hit @ VM6:1392

VM6:1394 #%#//scriptlet("set-constant", "Document.prototype.browsingTopics", "undefined") trace end

VM6:1686 #%#//scriptlet("set-constant", "document.browsingTopics", "undefined") trace start

VM6:1688 console.trace
hit @ VM6:1688

VM6:1690 #%#//scriptlet("set-constant", "document.browsingTopics", "undefined") trace end

VM6:1982 ~coupang.com,~coupangcdn.com#%#//scriptlet("set-constant", "PartnersCoupang", "undefined") trace start

VM6:1984 console.trace
hit @ VM6:1984

VM6:1986 ~coupang.com,~coupangcdn.com#%#//scriptlet("set-constant", "PartnersCoupang", "undefined") trace end

Next.js passing objects and array in query

I want to pass object (which also contain an array) as query parameter to my request.

const fa = {
  'variants.attributes.Clothing_color': {
    terms: ['Navy Blue', 'Golden Croissant'],
  },
};

const serialize = function (obj) {
  var str = [];
  for (var p in obj)
    if (obj.hasOwnProperty(p)) {
      str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
    }
  return str.join('&');
};

 const urlP = serialize(fa);
            router.push({
              pathname: router.asPath.split('?')[0] as string,
              query: { facets: urlP },
            });

In my url the query parameter shown as ?facets=variants.attributes.Clothing_color%3D%255Bobject%2520Object%255D

In my backend I want to use Object.entries(facets) but it creates array of each string instead of array of objects.

1.)What is the right way to pass Objects as query parameter in Next.js?
2.)What is the right way to perform Objects.entries() ?

Thanks in Advance

How to fix closure in react when using addEventListener and useState

I’ve made a simple example of a counter and want to console log value on mouse click, but it always displays 0. How can fix it?

import "./App.css";
import { useState } from "react";
import { useEffect } from "react";

function App() {
  const [num, setNum] = useState(0);

  const handler = () => {
    console.log(num);
  };

  useEffect(() => {
    window.addEventListener("click", handler);
  }, []);

  return (
    <div className="App">
      <header className="App-header">
        <div
          onClick={() => {
            setNum(num + 1);
          }}
        >
          Add
        </div>
        <h1>{num}</h1>
      </header>
    </div>
  );
}

export default App;

image

Why this function return undefined on NodeJS? [duplicate]

I don’t know why this function returns undefined and not the user found (the id exists because I’ve copied it from the database).

getAllUsers = async() => {
  var user
  new Connection().connect().then((result, err) => {
    if (!err && result.status == 1) {
      user = User.findById('629d0876d43e0fdad16a1772')
    }
  })
  console.log(user) //It returns undefined, but not User.findById('629d0876d43e0fdad16a1772')
  return user
}

ASP.NET MVC @Url.Action redirects only to controller, not to action

I am learning the basis of HTML, Bootstrap & JavaScript. I want to use bootstrap nav class for navigation. The first problem: bootstrap doesn’t work in shared view _Layout.cshtml and buttons look like:

enter image description here

But the content of index.cshtml looks OK.
The second problem: when I click on Messages, it redirects me only to controller ../User, not to its action ../User/Index. I have no idea why it does not work.

Below my _Layout.cshtml code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
    <script src="~/lib/twitter-bootstrap/js/bootstrap.js"></script>
    <title>@ViewData["Title"] - title</title>
    <link rel="stylesheet" href="~/css/site.css" />
</head>
<body>
    <header>
        <ul class="nav nav-tabs">
            <li role="navigation" class="active"><a href="#">Home</a></li>
            <li role="navigation"><a href="#">Profile</a></li>
            <li role="navigation"><a href="@Url.Action("Index", "User")">Messages</a></li>
        </ul>
    </header>
    <div class="container">
        <main role="main" class="pb-3">
            @RenderBody()
        </main>
    </div>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    @RenderSection("Scripts", required: false)
</body>
</html>

Why is the animation not reverse in GSAP?

I have question, I wanted reverse animation “showMenuList”(this is pink background), but this not working, where is mistake?

I tried paused,and so many method but this not working, please help

I know that this is mostly code but I don’t know what else to write XD

const menuToggler = document.querySelector(".toggler");
const menuTogglerHamburger = document.querySelector(".toggler .hamburger");

menuToggler.addEventListener("click", function () {
  //checking if there is a class animationToggler
  if (menuTogglerHamburger.classList.contains("animationToggler")) {
    //restart animation rotate
    menuTogglerHamburger.classList.remove("animationToggler");
    void menuTogglerHamburger.offsetWidth;
    menuTogglerHamburger.classList.add("animationToggler");
  }

  menuTogglerHamburger.classList.add("animationToggler");

  menuToggler.classList.toggle("show");
  menuToggler.classList.contains("show")
    ? showMenuList(true)
    : showMenuList(false);

  setTimeout(() => {
    //animation line on the cross
    menuTogglerHamburger.classList.toggle("active");
  }, 200);
});

//---------------------- Show menu list ----------------------//

const showMenuList = (e) => {
  console.log(e);
  const showMenuTl = gsap.timeline({ pause: true });

  e ? showMenuTl.play() : showMenuTl.reverse();

  showMenuTl
    .to(".nav-menu", 0.8, { css: { top: "50%" } })
    .to(".nav-menu", 0.4, { css: { width: "140vw", height: "140vw" } });
};
body {
    overflow: hidden;
}

nav {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-around;
    padding-top: 1em;
}

.toggler {
    display: flex;
    align-items: center;
    cursor: pointer;


}

.animationToggler {
    animation: animationTogglerMenu .8s ease;
}


.toggler p {
    margin: 0;
    text-transform: uppercase;
    font-size: 1.65rem;
    margin: 0 0 0 10px;
    z-index: 3;
}

.hamburger {
    z-index: 3;
}

.hamburger .line {
    height: 4px;
    width: 2.5em;
    background: #000;
    margin: .45em 0;
    border-radius: 50px;
    transition: .3s;
}

.active .one {
    transform: rotate(45deg) translateY(15px);
}

.active .two {
    background-color: transparent;
    transition: none;
}

.active .three {
    transform: rotate(-45deg) translateY(-15px);
}

.nav-menu {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3em;
    height: 3em;
    background-color: rgb(255, 117, 117);
    border-radius: 50%;
    /* opacity: 0.4; */
    z-index: 2;
}

.nav-menu ul {
    display: none;
}


@keyframes animationTogglerMenu {

    100% {
        transform: rotate(360deg);
    }
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div class="toggler">
        <div class="hamburger">
            <div class="line one"></div>
            <div class="line two"></div>
            <div class="line three"></div>
        </div>
        <p>Menu</p>
    </div>
    <div class="nav-menu">
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">Projekty</a></li>
            <li><a href="#">O nas</a></li>
            <li><a href="#">Kontakt</a></li>
        </ul>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
    <script src="main.js"></script>
</body>

</html>

https://codepen.io/jarek-babiak/pen/KKQGgME