How should I use the SCSS variables correctly with the VUE3 stack?

In the global file VUE3 of the project I write the SCSS variable.

введите сюда описание изображения

Further, in one of the modules I try to use it:

введите сюда описание изображения

I get an error.

введите сюда описание изображения

98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 error                                                                                                                                                  17:57:46

 error  in ./src/components/headerNav.vue?vue&type=style&index=0&id=14455714&lang=scss&scoped=true

Syntax Error: SassError: Undefined variable.
  ╷
6 │   background-color: $--color-second;
  │                     ^^^^^^^^^^^^^^^
  ╵
  E:Progi3vue3-perfect-goodssrccomponentsheaderNav.vue 6:21  root stylesheet


 @ ./node_modules/vue-style-loader??ref--9-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--9-oneOf-1-1!./node_modules/vue-loader-v16/dist/stylePostLoader.js!./node_modules/postcss-loader
/src??ref--9-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--9-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader-v16/dist??ref--1-1!./src/components/
headerNav.vue?vue&type=style&index=0&id=14455714&lang=scss&scoped=true 4:14-455 15:3-20:5 16:22-463
 @ ./src/components/headerNav.vue?vue&type=style&index=0&id=14455714&lang=scss&scoped=true
 @ ./src/components/headerNav.vue
 @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-l
oader-v16/dist??ref--1-1!./src/views/Home.vue?vue&type=script&lang=ts
 @ ./src/views/Home.vue?vue&type=script&lang=ts
 @ ./src/views/Home.vue
 @ ./src/router/index.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://192.168.0.102:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts

Question:
Why is this happening and how is it necessary to implement the task in the context of this technology stack?

P.S. The editor itself picks up the color of the variable correctly:

введите сюда описание изображения

Can’t read my variable outside of my function using Cheerio (JavaScript)

I am new to JavaScript and I am having troubles with my web-scraper program. I followed a tutorial to get cyptocurrencies value out of a website, but for some reasons I can’t read the variable “price” outside of my function.
Here’s my code

const axios = require("axios")
const cheerio = require("cheerio")
const{ Routes } = require("discord-api-types/v9");
const { parse } = require("dotenv");

    async function getPriceFeed() {
        try {
            const siteUrl = "https://coinmarketcap.com/currencies/raptoreum/"

            const {data} = await axios({
                method : "GET",
                url: siteUrl,
            })

            const $ = cheerio.load(data)
            const elemSelector = "#__next > div.bywovg-1.fUzJes > div.main-content > div.sc-57oli2-0.comDeo.cmc-body-wrapper > div > div.sc-16r8icm-0.eMxKgr.container > div.n78udj-0.jskEGI > div > div.sc-16r8icm-0.kjciSH.priceSection > div.sc-16r8icm-0.kjciSH.priceTitle > div"

            $(elemSelector).each((parentIdx, parentElem) => {
                    $(parentElem).children().each((childIdx, childElem) =>{
                       var price = $(parentElem).text();
                       return price;
                })
            })
        }catch(err) {
            console.error(err)
        }
    };

console.log(price)

Thank you for your help,
Vicriya

How to change require statements inline using codemod (jscodeshift)?

Hi I’m trying to write a codemod which moves my require statement from top of the file to inside class constructor function.

const moduleA = require('moduleA');
const moduleB = require('../moduleB');

class Example {
  constructor(context) {
    super(context);
    this.lazy("moduleA", () => { new moduleA() }
    this.lazy("moduleB", () => { new moduleB() }
  }

  async callThis() {
     this.moduleA.callThatMethod();
  }
}

These require statements on top of the file taking long time, which is only used if that API is called at-least once. So as the require is being cached by Node.js at process level anyway. I’m trying to move the require statement inside the arrow function.

Like Below

class Example {
  constructor(context) {
    super(context);
    this.lazy("moduleA", () => { 
       const moduleA = require('moduleA');
       return new moduleA() 
    }
    this.lazy("moduleB", () => {
      const moduleB = require('../moduleB');
      return new moduleB() 
    }
  }

  async callThis() {
     this.moduleA.callThatMethod();
  }
}

I’m having trouble achieving this, because i dunno how to select the “lazy” function defined and then move the top require.

Any help is much appreciated Thanks

How to disconnect only one element using MutationObserver in JavaScript?

Well, I want to do something like this:

const config_observer = { attributes: true};
const observer = new MutationObserver(function(mutations) {
  console.log("changed")
});

observer.observe(document.body.querySelector("#random-id"), config_observer);
observer.observe(document.body.querySelector("#something"), config_observer);

document.body.querySelector("button").addEventListener("click", () => {
  observer.disconnect(document.body.querySelector("#something"));
});

I know that the disconnect function doesn’t have parameters. So, is there some way to do this or something like that?

Thanks Advanced.

Paginate running correctly but not passing objects to client

My paginate function is returning the documents correctly on the console but it’s not properly passing them to the client. I have the paginate function set as a middleware below:

module.exports.paginatedResults = async (req, res, next) => {
    const page = parseInt(req.query.page);
    const limit = parseInt(req.query.limit);

    const startIndex = (page - 1) * limit;
    const endIndex = page * limit;

    const results = {}

    if(endIndex < await Event.countDocuments().exec()) {
        results.next = {
            page: page + 1,
            limit: limit
        }
    }

    if(startIndex > 0) {
        results.previous = {
            page: page - 1,
            limit: limit
        }
    }

    results.results = await Event.find().limit(limit).skip(startIndex).exec()
    res.paginatedResults = results;
    console.log(results);
}

I then pass the results to my route handler using below:

const { paginatedResults } = require('../middleware');

router.route('/')
    .get(paginatedResults, catchAsync (events.index))

And then would like to display it on my events index page w/ below function:

module.exports.index = async (req, res) => {
    res.render('events/index', {  paginatedResults })
};

When I hit the route http://localhost:3000/events?page=3&limit=2, the proper documents log in my terminal (because of the console.log in my paginateResults middleware function) but the browser spins and time’s out.

I know my data-flow is breaking down somewhere because the results are not being sent to the client, but where?

Cesium separate timeline widget is not working properly

I want to display cesium clock and timeline widget inside a different div container outside of the cesium container. With the help of this link I’ve created a separate clock widget and applied animation on an entity. Animation is working but the clock widget is not working. It seems like default clock widget is working not the newly created. Sandcastle link

var viewer = new Cesium.Viewer("cesiumContainer", {
  infoBox: false, //Disable InfoBox widget
  selectionIndicator: false, //Disable selection indicator
  shouldAnimate: true, // Enable animations
  terrainProvider: Cesium.createWorldTerrain(),
});

//Enable lighting based on the sun position
viewer.scene.globe.enableLighting = true;

//Enable depth testing so things behind the terrain disappear.
viewer.scene.globe.depthTestAgainstTerrain = true;

var _currentSysDT = new Date(); 

function onTimelineScrubfunction(e) {
        clock = e.clock;
        clock.currentTime = e.timeJulian;
        clock.shouldAnimate = false;
    }

var timeControlsContainer = document.getElementById('timeControlsContainer');
  // viewer.animation.viewModel.timeFormatter = LocalFormatter;
var clock = new Cesium.Clock();
clock.startTime = Cesium.JulianDate.fromDate(_currentSysDT);
clock.currentTime = Cesium.JulianDate.fromDate(_currentSysDT);
clock.clockRange = Cesium.ClockRange.LOOP_STOP;

var clockViewModel = new Cesium.ClockViewModel(clock);
clockViewModel.startTime = Cesium.JulianDate.fromDate(_currentSysDT);
clockViewModel.currentTime = Cesium.JulianDate.fromDate(_currentSysDT);

var animationContainer = document.createElement('div');
animationContainer.className = 'cesium-viewer-animationContainer';
timeControlsContainer.appendChild(animationContainer);

var animViewModel = new Cesium.AnimationViewModel(clockViewModel);
var animation = new Cesium.Animation(animationContainer, animViewModel);
var timelineContainer = document.createElement('div');
timelineContainer.className = 'cesium-viewer-timelineContainer';
timeControlsContainer.appendChild(timelineContainer);

var timeline = new Cesium.Timeline(timelineContainer, clock);
timeline.addEventListener('settime', onTimelineScrubfunction, false);
timeline.zoomTo(clock.startTime, clock.stopTime);

clockViewModel.shouldAnimate = true;
animViewModel.snapToTicks = false;
animViewModel.pauseViewModel.command(); //comment this for default play
timeline.zoomTo(clock.startTime, Cesium.JulianDate.addSeconds(clock.startTime, 60, new Cesium.JulianDate()));
clock.onTick.addEventListener(function (clock) {
  
});

window.setInterval(function () {
    clock.tick();
}, 32);

var start = Cesium.JulianDate.addSeconds(Cesium.JulianDate.fromDate(_currentSysDT), 0, new Cesium.JulianDate());
var stop = Cesium.JulianDate.addSeconds(Cesium.JulianDate.fromDate(_currentSysDT), 120, new Cesium.JulianDate());

var positions = [{"lat":"23.14291673","lon":"73.60544359","alt":"33.79739465869949"},{"lat":"23.14291736","lon":"73.60558935","alt":"33.705623697852786"},{"lat":"23.14284330","lon":"73.60553133","alt":"33.280035949546644"},{"lat":"23.14284640","lon":"73.60546898","alt":"33.219775982790594"}];

var positionProperty = new Cesium.SampledPositionProperty();
positions.forEach((p,i)=>{
  let _pos = Cesium.Cartesian3.fromDegrees(parseFloat(p.lon), parseFloat(p.lat), parseFloat(p.alt));
  let _time = Cesium.JulianDate.addSeconds(start, i, new Cesium.JulianDate());
  positionProperty.addSample(_time, _pos);

});

var entity = viewer.entities.add({
  //Set the entity availability to the same interval as the simulation time.
  availability: new Cesium.TimeIntervalCollection([
    new Cesium.TimeInterval({
      start: start,
      stop: stop,
    }),
  ]),

  //Use our computed positions
  position: positionProperty,

  //Automatically compute orientation based on position movement.
  orientation: new Cesium.VelocityOrientationProperty(positionProperty),

  //Load the Cesium plane model to represent the entity
  model: {
    uri: "../SampleData/models/CesiumMan/Cesium_Man.glb",
    minimumPixelSize: 64,
  },

  //Show the path as a yellow line sampled in 1 second increments.
  path: {
    resolution: 1,
    material: new Cesium.PolylineGlowMaterialProperty({
      glowPower: 0.1,
      color: Cesium.Color.YELLOW,
    }),
    width: 10,
  },
});

viewer.trackedEntity = entity;

Must use import to load ES Module .eslintrc.js

I am trying to fix this problem for hours. I’ve read nearly every post about this, but still, I came to no solution.

I am trying to deploy a firebase-function with the “https got-library” dependency, but no matter what I do, nothing works. I am not the best with node-js or typescript (usually a kotlin frontend-dev), so I have no clue what the error wants from me.

Tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": false,
    "esModuleInterop": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ],
}

.eslintrc.js

module.exports = {
  root: true,
  env: {
    es6: true,
    node: true,
  },
  extends: [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "google",
    "plugin:@typescript-eslint/recommended",
  ],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: ["tsconfig.json", "tsconfig.dev.json"],
    sourceType: "module",
  },
  ignorePatterns: [
    "/lib/**/*", // Ignore built files.
  ],
  plugins: [
    "@typescript-eslint",
    "import",
  ],
  rules: {
    "quotes": ["error", "double"],
    "import/no-unresolved": 0,
    "linebreak-style": ["error", "windows"],
    "indent": "off",
    "object-curly-spacing": "off",
    "no-tabs": 0,
    "max-len": "off",
    "require-jsdoc": 0,
    "no-empty": [0, "allow-empty-functions", "allow-empty-catch"],
    "@typescript-eslint/no-explicit-any": ["off"],
    "@typescript-eslint/naming-convention": ["off"],
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/explicit-module-boundary-types": "off",
    "@typescript-eslint/no-var-requires": "off",
    "no-mixed-spaces-and-tabs": 0,
    "camelcase": 0,
  },
};

package.json

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "14"
  },
  "type": "module",
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/functions-framework": "^2.1.0",
    "@types/stripe": "^8.0.417",
    "firebase-admin": "^10.0.1",
    "firebase-functions": "^3.14.1",
    "firebase-tools": "^10.0.1",
    "form-data": "^4.0.0",
    "got": "^12.0.0",
    "iso3166-alpha-converter": "^1.0.0",
    "mailgun.js": "^4.1.0",
    "stripe": "^8.193.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.8.0",
    "@typescript-eslint/parser": "^5.8.0",
    "eslint": "^8.5.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.22.0",
    "firebase-functions-test": "^0.3.3",
    "typescript": "^4.5.4"
  },
  "private": true
}

Error

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:UsersImMorDocumentsFirebaseFunctionsfunctions.eslintrc.js
require() of ES modules is not supported.
require() of C:UsersImMorDocumentsFirebaseFunctionsfunctions.eslintrc.js from C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modules@eslinteslintrcdisteslintrc.cjs is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename .eslintrc.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:UsersImMorDocumentsFirebaseFunctionsfunctionspackage.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at Object.module.exports [as default] (C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modulesimport-freshindex.js:32:59)
    at loadJSConfigFile (C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modules@eslinteslintrcdisteslintrc.cjs:2531:47)
    at loadConfigFile (C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modules@eslinteslintrcdisteslintrc.cjs:2615:20)
    at ConfigArrayFactory.loadInDirectory (C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modules@eslinteslintrcdisteslintrc.cjs:2808:34)
    at CascadingConfigArrayFactory._loadConfigInAncestors (C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modules@eslinteslintrcdisteslintrc.cjs:3772:46)
    at CascadingConfigArrayFactory.getConfigArrayForFile (C:UsersImMorDocumentsFirebaseFunctionsfunctionsnode_modules@eslinteslintrcdisteslintrc.cjs:3693:18)

Function I want to deploy

// THIS IS MAKING THE PROBLEM
import got from "got";

export async function doOnDeletedUser(
    // SOME OTHER STUFF
) {
    const uid = user.uid;
    // SOME OTHER STUFF
}

how to change value of object in array using setState with React

hello everyone good evening,

I have array of object set in state and i would like to change some object in the array.

so here is my array us you can see:

    const [CategoriesArr, setCategoriesArr] = useState([
    {
        image: anime,
        nameByCategories: "Aninate",
        allCard: [
            silverCard, blackCard
        ],
    },
    {
        image: vacation,
        nameByCategories: "Vacation",
        allCard: [
            blackCard, silverCard
        ],
    },])

i tried to change the allCard to: allCard:blackCard, blackCard

with this way:

setCategoriesArr([
{
    ...CategoriesArr[0],
    allCard: [
        silverCard, silverCard
    ]
}])

the problem is after the setState i get new array with changes that i want and also the last array so it means like this

  {
        image: anime,
        nameByCategories: "Aninate",
        allCard: [
            blackCard, blackCard
        ],
    },
    {
        image: vacation,
        nameByCategories: "Aninate",
        allCard: [
            silverCard, blackCard
        ],
    },
  {
        image: anime,
        nameByCategories: "vacations",
        allCard: [
            blackCard, silverCard
        ],
    },

i would like to understand i can i get new array exact like that:

    const [CategoriesArr, setCategoriesArr] = useState([
{
    image: anime,
    nameByCategories: "Aninate",
    allCard: [
        silverCard, blackCard
    ],
},
{
    image: vacation,
    nameByCategories: "Vacation",
    allCard: [
        blackCard, blackCard
    ],
},])

pleas.

i hope you guys going to help me 🙂

items.map is not a function react

I’m having a problem with fetching data from my api, and displaying it on a web page. I am getting this error : “items.map is not a function”. Im not sure whether this is a problem with this code or maybe my code for my get request in the api, I’ll post both codes just in case.

I’ll paste my code below without the link to my api.
Thanks,

import React from "react";

class App extends React.Component {


  constructor(props) {

    super(props);

    this.state = {
        items: [],
        isLoaded: false
    }

}

componentDidMount() {

  fetch(" api link ")
      .then(res => res.json())
      .then(json => {
        this.setState({ isLoaded: true, items: json });
      }).catch((err) => {
          console.log(err);
      });

}


render() {

  const { isLoaded, items } = this.state;

  if (!isLoaded)
      return <div>Loading...</div>;

  return (
      <div className="App">
          <ul>
              {items.map(item => (
                  <li key={item.oid}>
                      Name: {item.rows.productName} | Condition: {item.rows.productCondition}
                  </li>
              ))}
          </ul>
      </div>
  );

}

}

export default App;

Api code:

async function getComments(req) {
   let status = 500, data = null;
   try {

         const sql = 'SELECT * FROM products';
         const rows = await db.query(sql);

         if (rows) {
            status = 200;
            data = {
                rows,

            };
         } else {
            status = 204;
         }
     
   } catch (e) {
      console.error(e);
   }
   return { status, data };
}


app.get('/demo/api_project', async (req, res) => {
   const { status, data } = await getComments(req);
   res.status(status);
   if (data) res.json(data);
   else res.end();
})

Javascript NodeJS – Can we make a local function variable becomes a global variables inside of class? [duplicate]

I’ve been trying to make these code works what I expected, but it doesn’t really works what I expected

import fetch from 'node-fetch';
const BASE_URL = 'https://estra-api.herokuapp.com/';

let EstraLoader = class Estra {
    loadAPI() {
        var data = '';
        fetch(BASE_URL)
        .then(function (response) {
        return response.json();
    })
        .then(function (myJson) {
        data = myJson;
        return data["Version"];
    });
}};

let EstraJS = new EstraLoader();
console.log(EstraJS.loadAPI());

The output always undefined, is there anything I can change from this codes that I made?

All I did want was the return data["Version"]; gives output by using console.log(EstraJS.loadAPI());

Render component after keyboard closes or listen to keyboard close event in react app in cordova android

I am migrating a ‘work-in-progress’ react.js application to an android app using cordova.
all seems to work fine except for a component that doesnt render itself peoperly when the keyboard closes, the component generally looks like this.
enter image description here

Now when you click on an input and close it the view re renders just fine:
enter image description here

But once you fill it and close the keyboard the component doesnt re render itself:
enter image description here
enter image description here

the component just gets stuck like that, the easy solution would obviously be to “force render” by setting the state again, the issue is that I cant seem to find a way to listen to keyboard changes on this react-cordova app, also why would the component re render itself when the form is empty but not when its filled?

I dont’ understand why I have a message error with my ROUTE POST API?

I am a project, and my goal is to create an API. During authentication a user can create a sauce with different fields. I am working with mongoDB. When I submit the form, the image saves well in my backend, but nothing on the page and nothing on collection (mongodb atlas).

This is what I have to respect :
request body :{ sauce: String,image: File }
type of response :{ message: String }Verb
And which is recorded from the frontend. I just have to take care of the backend and not touch anything on the frontend side.

I have successfully connected in my mongoose apps.js file, and I have no error on the connection. But as the form is not displayed, nothing is sent on mongodb atlas too.

I have this message : SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse ()
at exports.createThing .

exports.createThing = (req, res, next) => {
  const thingObject = JSON.parse(req.body.thing);
  delete thingObject._id;
  const thing = new Thing({
    ...thingObject,
    imageUrl: `${req.protocol}://${req.get("host")}/images/${
      req.file.filename
    }`,
  });
  thing
    .save()
    .then(() => res.status(201).json({ message: "
registered object !" }))
    .catch((error) => res.status(400).json({ error }));
};

How to check if array of objects contains any value from array

Hi so i have an array of integers which i have been trying to check against my array of objects. I only want to check that ANY of the values in the array are within the objArray, it does not need to be ALL.

const objArray = [{id: 1},{id: 2},{id: 3}]

const array = [1, 2]

This is what i tried but i think i am probably way off the logic, i end up getting false every time i run the below code.

array.includes(objArray.some(o => o.id))

Essentially my overall goal to is to validate that any return true and then continue with code otherwise throw an error.

Thank you in advance!