Vue Axios post timeout not effect

This is my function define, set timeout 1000 * 60 * 5 can’t effect, but request is working.

export function cmdActiveVsi (data) {
  return Vue.prototype.$api.post(baseUrl + '/com/mpls/v1/execVsiConfig', data, 1000 * 60 * 5)
}

This is Interceptors config, This config timeout is effect.

let instance = axios.create({
  headers: {
    'Content-Type': 'application/json;charset=UTF-8'
  },
  timeout: 1000 * 60
})

How can I stop create react app fast refresh on change to only act on save?

I’m not sure how can I make Fast_Refresh only activate the compilation on save rather than on any change made to source, as I’m typing;

at the moment its activated on any change without even needing a file save, and thats a little annoying for some large components, as I’m making a change it breaks the interface.
I thouhgt it’s watching filesystem, but something else is triggering the compilation as I’m typing…

I am using vscode, react project + typescript created using create-react-app using react “^17.0.2” on a large scale project.

forloop.counter0 in my django template is not working under original for loop

I have a for loop that goes through a list of inspections. I’d like to manipulate the things inside the tag depending on different situations. For test, I tried to using jquery to print out the id of the element as it iterates, but the forloop seems to be stuck at 0. when I put inside the html it will iterate, but when I put inside the attribute ‘id’, it will not iterate. based on the code below, it should iterate as many times as there is i in inspections. but it wont. I also tried to get a console.log() fo the innerHTML of my but all I get is the first item repeated over and over instead of going down the list (on the webage however it looks lile it iterated ok, just not on the backend I guess?).
note that jquery was imported at the beginning of the html. this is just snippet of issue.

I’d appreciate any help.

my code:

<div class="tab-pane fade" id="nav-inspection" role="tabpanel"
                                 aria-labelledby="nav-inspection-tab">
                                <div class="container"></br></br>
                                    {% for i in inspections %}
                                        <div class="card - mb-3" style="width: 40 rem;">
                                            <div class="card-body">
                                                <h3 class="card-title">{{i.Title}} - <span title="" id="s{{forloop.counter0}}">{{i.Condition}}</span>
                                                </h3>
                                                <script type="text/javascript">
                                                    console.log(document.querySelector('[title]').innerHTML);
                                                    $(document).ready(function(){
                                                        alert($('[title]').attr("id"));
                                                    });
                                                </script>
                                                <p>{{i.Desc}}</p>
                                                <h4><span class="badge badge-primary">{{i.Cost}}</span></h4>
                                            </div>
                                        </div>
                                    {% endfor %}
                                </div>
                            </div>

My dispatch function works but is not updating redux state

I understand that this question has been asked several times but my example doesn’t suffer from any of the solutions provided in the other examples. I hope someone can help, thanks in advance.

Here’s my slice, screenSlice.js:

import { createSlice } from '@reduxjs/toolkit';

//this slice sets the state of the screens Y axis
export const screenSlice = createSlice({
  name: 'screenYPlacement',
  initialState: {
    offsetY: 0,
  },
  reducers: {
    setoffsetY: (state, action) => {
      return {
        ...state,
        offsetY : action.payload
      }
    }
  }
});

export const { setoffsetY } = screenSlice.actions
export default screenSlice.reducer 

My store, store.js :

import { configureStore } from '@reduxjs/toolkit';
import screenReducer from './screenSlice';

export default configureStore({
  reducer: {
    offsetY: screenReducer
  },
});

The file in which it is called, app.js:

import React, { useEffect} from 'react'

import './App.scss';

import { useDispatch } from 'react-redux';
import { setoffsetY } from './redux/screenSlice';

import Header from './components/header/Header';
import Hero from './components/hero/Hero';

function App() {
  const dispatch = useDispatch()
  //this function will use the redux reducer to save the Y axis to redux
  const handleScroll = () => dispatch(setoffsetY(window.pageYOffset));
  
  useEffect(() => {
    window.addEventListener('scroll', handleScroll);
    return () => window.removeEventListener('scroll', handleScroll);
  });

  return (
    <div className="App">
      <Header/>
      <Hero/>
    </div>
  );
}

export default App;

Axios get request status 503 if i call it inside a for loop

I want to make ten api calls to populate an array. If i make the same api call but outside of the for loop i don’t get any problem. But doing it inside the for loop i get some succesfull requests and a ton with a 503 status code, service unavaiable.

Here is my js:

function generatePersonJson() {
  const promise = axios.get(url, {
    headers: {
      Accept: "application/json",
      "User-Agent": "axios 0.21.1",
    },
  });
  const dataPromise = promise.then((response) => response.data);
  return dataPromise;
}

const createPerson = async () => {
  generatePersonJson()
    .then((data) => {
      if (data) {
        return data
      }
    })
    .catch((err) => console.log(err));
};

const createPersons = async () => {
  let personsArray = [];
  for (let i = 0; i < 11; i++) {
    const dev = await createPerson();
    personsArray.push(dev);
  }
  console.log(personsArray);
};

createPersons();

I get the error in the catch block inside the createPerson and it looks like this: response: { status: 503, statusText: 'Service Unavailable',

How do I make algolia search work with kitsu’s anime content api — using the index/indices and key/s provided by kitsu?

I cant seem to figure out how to connect algolia/algoliasearch to kitsu api: https://hummingbird-me.github.io/api-docs/#tag/Algolia

I was able to do the OAuth part. I am now trying to connect it to algolia.

Per kitsu:

Kitsu uses Algolia for searching. Algolia’s search provides more accurate search results and allows you to build complex search filters to find exactly what you want.

And as per the documentation I need to retrieve the keys and indices that I will use to connect to algolia:

All Algolia Keys – Get all the Algolia Keys needed to search Kitsu with Algolia.

So I was able to that as well — I had to fetch it from kitsu:

fetch('https://kitsu.io/api/edge/algolia-keys')
    .then(res => res.json())
    .then(data => console.log(data))

screenshot of the keys / indices

I have tried creating an account with algolia. I found tutorials but all of them would just create their own index and import dummy JSON data.

I was able to do this (create a new empty index from scratch):

https://github.com/algolia-samples/api-clients-quickstarts/blob/master/javascript/simple.js

…but it is still not giving any hint or example how to consume or use an external key or index that is not from my own algolia account. I just need to use the index and key that i got from that GET request from kitsu so that i can implement search using algolia on kitsu’s anime content on the website im trying to build.

Selecting a single input value from an HTML file using only javascript

I am trying to do a form validation WITHOUT jquery. I have found this code, but I am not sure how to convert it from Jquery to plain Javascript.
I found this code here

$('.clickme').click(function() {

  alert($(this).prev().val())
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="hidden" name="myvalue" class="form-control input_text" value="aaa" />
<input type="button" class="clickme" value="Get Value" />

<input type="hidden" name="myvalue" class="form-control input_text" value="bbb" />
<input type="button" class="clickme" value="Get Value" />

<input type="hidden" name="myvalue" class="form-control input_text" value="ccc" />
<input type="button" class="clickme" value="Get Value" />


<input type="hidden" name="myvalue" class="form-control input_text" value="ddd" />
<input type="button" class="clickme" value="Get Value" />

<input type="hidden" name="myvalue" class="form-control input_text" value="eee" />
<input type="button" class="clickme" value="Get Value" />

Any help with this would be amazing. I have multiple forms in one HTML file, all with the same input variables, and I need the functions to only run for when that specific input button is clicked.

Destructuring Class methods loses (this) context [duplicate]

i’m wondering if it’s possible to destructure the properties/methods from an instance of a class or function while maintaining scope across the destructured variables without having to use call() every time i need that method? For example:

class Pearson {}

Pearson.prototype.speak = function speak(){
  return this.sayHi
};

Pearson.prototype.speakOutLoud = function speakOutLoud(){
  return this.speak().toUpperCase()
};

const pearson = Object.assign(new Pearson(), {sayHi:"hi!!"});

const {speak, speakOutLoud} = pearson;

speak.call(pearson) // hi!!
speakOutLoud.call(pearson) // HI!!

I want to avoid the call() because i have a bunch of methods, and i want to know if exist any cleaver solution to this.

Some questions about css (animation)

so here is the code https://codepen.io/Dobrodeetel/pen/ZEaqVap.

This code partially repeats what I have on the site. therefore questions about why it is so – unnecessary.
It works like this – click on any line – an additional line appears with a table inside (you can remove it if you click again on the same line) in which there is a line when you click on which another internal table will appear (which is also removed when you click again).

Have a few questions:

1 – if you look at the third table, you can see the row overlap (css hover).
the question itself is how to do the same only for the first table (it is possible for the second one as well)?
i.e. write something like

.table_blur tbody:hover tr:hover td {
  background: #8981ce85;
  text-shadow: none;
}

as commented out in table_blur on line 32, the line with the second table will overlap. I need to make sure that such rows (with tables inside) are NOT repainted.
I was offered an option that is also at the end of table_blur (line 37) but it does not work

2 – there is this code https://codepen.io/Dobrodeetel/pen/ExXEemr.
It’s about opening animation. how to apply such animation to my tables?
also found this code http://jsfiddle.net/1rnc9bbm/4/. which works without js at all? Well, of course I need when pressed.

So – how to attach a similar animation to the May version? that is, opening and closing until the disappearance?
I really don’t care how it works. just because my table is built right away – the code with the active class does not work.

Also how to make animation relative to width? as you can see, the third table greatly stretches the ENTIRE table (on my site it’s the same and can’t be changed in any way, since the number of columns is different). how to make a stretch animation?

That’s all. the answer to any question will greatly reduce my work)

Tabulator removeFilter doe not remove the filter No matching filter type found, ignoring: like

I am trying to remove the filter which I thought will be the easiest part of the whole tabulator but it seems to be like am missing some core things here. Below is my code which is pretty straightforward.

btn.onclick = function () {
var FilterToRemove = $(btn).closest('p').text();        // Finds the closest P tag
console.log(FilterToRemove);
var filters = table.getFilters();
filters = filters.flat();
for (let j=0; j<filters.length;j++){
  AlreadyAppliedFilter=filters[j]['value'];
  console.log(filters[j]);
  console.log(typeof(filters[j]['type']));

  if(AlreadyAppliedFilter==FilterToRemove){
    table.removeFilter("filename",filters[j].type,filters[j]['value']);
    console.log(FilterToRemove);
    console.log("Removed");
  }
};

};

but am always getting this error

Filter Error – No matching filter type found, ignoring: like

The problem is whenever I get the type of my filter from getFilters the type of “type” is a string but tabulator expects it to be an object.

any help would be highly appreciated. Thanks 🙂

in Next Js why is index.js file is rendering 2 times giving a div twice on the website

I was trying to build a simple e-commerce website with nextjs + redux + tailwind

the problem is
In this the last 2 p tag are repeated

i think the problem is with ssr in nextjs
indexjs is rendered one time on server side and on client side too
i don’t know if getInitialProps would solve this issue.
i tried using class components in _app.js and adding getInitialProps into it
didn’t work doe.

my /index.js is like

import React from "react";
import { NavbarContainer } from "../components/Navbar/Navbar.container";
import {
  Box,
} from "@chakra-ui/react";
const Home = () => {
  return (
    <>
      <Box className="">
        <NavbarContainer/>
        <Box spacing={3} className="btmList"> iainicback</Box>
        <Box spacing={3} className="btmList"> iainicback</Box>
      </Box>
    </>
  );
};

export default Home;

my _app.js is like

import App from "next/app";
import { Provider } from "react-redux";
import { store } from "../redux";
import React from "react";
import "../styles/globals.css";
import { extendTheme } from "@chakra-ui/react";
import { Chakra } from "../styles/Chakra";

// 2. Extend the theme to include custom colors, fonts, etc
const colors = {
  brand: {
    900: "#1a365d",
    800: "#153e75",
    700: "#2a69ac",
    200: "#384d",
  },
};

const theme = extendTheme({ colors });

const MyApp = (props) => {

    const { Component, appProps } = props
    return (
      <Provider store={store}>
        <Chakra theme={theme} cookies={appProps?.cookies}>
          <Component {...appProps} />
        </Chakra>
      </Provider>
    );
  
}

export default MyApp

this is my folder structure

Simple & Native react-d3-library Bar chart example

I had been investigating throug videos/content and I couldn’t find a complete example about How-To build a simple Bar chart with “react-d3-library”, all I could find was about getting D3 code and convert it to React. Even those guides were unhelpful.

Thanks in advance…

This is a very simple component implementation of react-d3-library to display a Bar chart but something is missing and I don’t know what it is. It doesn’t crash but simply doesn’t show anything.

What is missing? (The code does not follow good practices with the purpose to be simple and basic pursuit an educational goal)

import React, { useEffect, useState } from 'react'
import axios from 'axios'
import rd3 from 'react-d3-library'
import './App.css';

const BarChart = rd3.BarChart;

function App() {
  const [state, setState] = useState({d3: ''})
  
  useEffect(() => {

    (async () => {
      let data = {}
      data.width = 500;
      data.height = 750;
      data.margins = {top: 20, right: 10, bottom: 0, left: 10}
      data.yAxisLabel = 'Y VALUE';
      data.ticks = 10;
      data.barClass = 'barChart';
      data.dataset = []
      const response = await axios(`https://apidatos.ree.es/es/datos/demanda/evolucion?start_date=2022-01-01T00:00&end_date=2022-03-06T23:59&time_trunc=day`)
      const values = response.data.included[0].attributes.values
      values.forEach(item => (data.dataset.push({label: item.datetime.split("T")[0],value:item.value})))
      console.log("values",values)
      console.log("data.dataset",data.dataset)
      setState({d3:data})
    })()
  
  },[])

  return (
    <div className="App">
      <header className="App-header">
        {
          Object.keys(state.d3).length
            ? <BarChart data={state} />
            : "null"
        }
      </header>
    </div>
  );
}

export default App;