How to get data from API “PokeAPI”

I have React component :

import React from "react";
import { Pokemons } from "../Pokemons";

class Main extends React.Component {
  state = {
    pokemons: [],
  };

  componentDidMount() {
    fetch("https://pokeapi.co/api/v2/pokemon?limit=20")
      .then((responce) => responce.json())
      .then((data) => this.setState({ pokemons: Object.values(data) }));
  }

  render() {
    return (
      <main className="container content">
        <Pokemons pokemon={this.state.pokemons} />
      </main>
    );
  }
}

export { Main };

The API I’m using is PokeAPI

My task is to display data about the first 20 Pokémon (which is what I’m trying to do in fetch() ). But I don’t get exactly what I need:

Console information.png

That is, JSON with four elements comes in response, the one I need is in the last one ( 3: ):

Console information 2.png

**In addition, each of the twenty objects (Pokémon) has a name and a link: **

Console Information 3.png

From this I need only the name, the rest of the necessary information (type, height, sprite) are data on these links. Example data in the link:

Data from link.png

In fact, the name of the pokemon is also in the data contained in these links.

I have never come across such an API structure before =(

Question – Help me get the name, type, sprite, height and weight of the Pokémon…

Sendinblue redirect

I included the Sendinblue Plugin to my WordPress Site which has the Avada Theme, so I found out, that the Plugin of Sendinblue has a few problems with some themes.
When I submit a Contactform formular to send it, I get this message:

{“status”:”success”,”msg”:{“successMsg”:””,”errorMsg”:””,”existMsg”:””,”invalidMsg”:””},”redirect”:””}

The only similair question I found was -> https://wordpress.org/support/topic/displays-plain-success-error-exist-messages-after-sending-form/ but there was no working solution.

Did somebody had the same issue before ?

Javascript between cells in Google Colab

I’m trying to get ipyvizzu, a JS charting library’s Jupyter Notebook integration, to work inside Google Colab. It depends on Jupyter’s behavior that generated javascript codes are put in the same scope throughout the notebook. Basically, the code snippet below would work in Jupyter Notebook. However, it does not work in Google Colab, because Colab seems to put every cell output in a separate iframe. Can I change this behavior of Colab somehow? Or is there any solution to this problem?

from IPython.display import display_javascript
display_javascript("var a = 10", raw=True)
display_javascript("console.log(a)", raw=True)

Error evaluating Javascript output: ReferenceError: a is not defined

(not) working example:
https://colab.research.google.com/drive/1FcAuHwqinsnBiaBALUguFzIw1wzoU1sj?usp=sharing

Triggering Action on click of button from CRM Portal website

There was a requirement to send an email to specified users(Support contacts) when user click on Submit feedback button. I was wondering if there is any way to trigger an Custom Action on click of the button on Portal Website form.

I tried with javascript emailto but it opens new outlook window for sending email, i want to send it as a background process.

If there is any alternative way to do it that would be helpful.

enter image description here

Making bold text in JavaScript

I’ve never done something in JavaScript, thus apologies if my question is very basic.

I’m trying to manipulate (making words bold, or introducing numeration structure) the description (description:”____”) part in the following code.

module.exports = {
  siteTitle: 'Hi! I'm Francisco!',
  siteDescription: `Create your online curriculum in just a few minutes with this starter`,
  keyWords: ['gatsbyjs', 'react', 'curriculum'],
  authorName: 'Francisco Santos',
  twitterUsername: '_franciscodf',
  githubUsername: 'santosfrancisco',
  authorAvatar: '/images/avatar.jpeg',
  authorDescription: `Developer, passionate about what I do. Always interested in how the sites were made, I started to study HTML by hobby. <br />
    In 2012 I started working as a support technician and I approached the developers.
    In 2015, I started to study C # and started to contribute with the team giving maintenance in an application in C # and .NET. <br />
    I currently work as a frontend developer and mainly work with <strong>Javascript, NodeJS e React.</strong>`,
  skills: [
    {
      name: 'HTML',
      level: 70
    },
    {
      name: 'CSS',
      level: 60
    },
    {
      name: 'Javascript',
      level: 50
    },
    {
      name: 'NodeJs',
      level: 40
    },
    {
      name: 'React',
      level: 60
    },
    {
      name: 'Git',
      level: 70
    },
    /* more skills here */
  ],
  jobs: [
    /* more jobs here */
    {
      company: "Gympass",
      begin: {
        month: 'sep',
        year: '2019'
      },
      duration: null,
      occupation: "Frontend developer",
      description: "<b>str</b> I am <b>part</b> of the bold(Corporate team), responsible for the development and maintenance of the employee management platform, giving more and more autonomy to partner +43 677 62431314companies."
  
    },  {
      company: "Lendico",
      begin: {
        month: 'apr',
        year: '2018'
      },
      duration: null,
      occupation: "Frontend developer",
      description: "I integrate the Frontend team responsible for developing and maintaining the online lending platform."
  
    }, 
  ],

I’ve already tried the basic syntax to do that usually, but since this obviously doesn’t work, I’m wondering if there is a simple way to do it within the “description:”

How do I remove non-uniform spacing between my table elements?

I am trying to make a paint website and for showing the colour palette, I use an HTML table of buttons that looks something like the following:
enter image description here

As you can see, the first three elements of both the rows are not uniformly spaced as the other elements in that row. To see why this problem must be occurring, I also used inspect but I couldn’t figure it out from there too because that gap wasn’t being shown in the margin, border or padding of the buttons.

enter image description here

I can’t understand this gap mainly because I have used uniform spacing and sizes for all the elements(You can see in the code snippet below). How do I correct this?

html {
    min-width: 1500px;
    position: relative;
    }

#toolset {
    width     : 100px;
    height    : 340px;
    position  : absolute;
    left      : 0px;
    top       : 50px; 
    background: #35d128;
}

#paint {
    position  : absolute;
    left      : 130px;
    top       : 50px;
}

#colorset {
    position  : absolute;
    left      : 0px;
    top       : 450px;
    width     : 300px;
}

#colorset td {
    width     : 18px;
    height    : 20px;
}
 
#title {
    position  : absolute;
    left      : 500px;
}

#penciltool {
    background: #358128; 
    color     : #f3f3f3;
    width     : 80px;
    height    : 25px;
    border    : 1px solid #33842a;
    -webkit-border-radius: 0 15px 15px 0;
    -moz-border-radius: 0 15px 15px 0;
    box-shadow: rgba(0, 0, 0, .75) 0 2px 6px;
}

#linetool {
    background: #358128; 
    color     : #f3f3f3;
    width     : 80px;
    height    : 25px;
    border    : 1px solid #33842a;
    -webkit-border-radius: 0 15px 15px 0;
    -moz-border-radius: 0 15px 15px 0;
    box-shadow: rgba(0, 0, 0, .75) 0 2px 6px;
}

#rectangletool {
    background: #358128; 
    color     : #f3f3f3;
    width     : 80px;
    height    : 25px;
    border    : 1px solid #33842a;
    -webkit-border-radius: 0 15px 15px 0;
    -moz-border-radius: 0 15px 15px 0;
    box-shadow: rgba(0, 0, 0, .75) 0 2px 6px;
}

#circletool {
    background: #358128; 
    color     : #f3f3f3;
    width     : 80px;
    height    : 25px;
    border    : 1px solid #33842a;
    -webkit-border-radius: 0 15px 15px 0;
    -moz-border-radius: 0 15px 15px 0;
    box-shadow: rgba(0, 0, 0, .75) 0 2px 6px;
}

#erasertool {
    background: #358128; 
    color     : #f3f3f3;
    width     : 80px;
    height    : 25px;
    border    : 1px solid #33842a;
    -webkit-border-radius: 0 15px 15px 0;
    -moz-border-radius: 0 15px 15px 0;
    box-shadow: rgba(0, 0, 0, .75) 0 2px 6px;
}

#resettool {
    background: #358128; 
    color     : #f3f3f3;
    width     : 80px;
    height    : 25px;
    border    : 1px solid #33842a;
    -webkit-border-radius: 0 15px 15px 0;
    -moz-border-radius: 0 15px 15px 0;
    box-shadow: rgba(0, 0, 0, .75) 0 2px 6px;
}                
<fieldset id="colorset" style="margin-top: 1.8%;">

        <table>
            <tr>
                <td><button style="height: 18px; width: 80px;" onclick="fill()">Fill</button>
                <td><button style="background-color: #000000; height: 15px; width: 15px;" onclick="color('#000000')"></button>
                <td><button style="background-color: #B0171F; height: 15px; width: 15px;" onclick="color('#B0171F')"></button>
                <td><button style="background-color: #DA70D6; height: 15px; width: 15px;" onclick="color('#DA70D6')"></button>
                <td><button style="background-color: #8A2BE2; height: 15px; width: 15px;" onclick="color('#8A2BE2')"></button>
                <td><button style="background-color: #0000FF; height: 15px; width: 15px;" onclick="color('#0000FF')"></button>
                <td><button style="background-color: #4876FF; height: 15px; width: 15px;" onclick="color('#4876FF')"></button>
                <td><button style="background-color: #CAE1FF; height: 15px; width: 15px;" onclick="color('#CAE1FF')"></button>
                <td><button style="background-color: #6E7B8B; height: 15px; width: 15px;" onclick="color('#6E7B8B')"></button>
                <td><button style="background-color: #00C78C; height: 15px; width: 15px;" onclick="color('#00C78C')"></button>
                <td><button style="background-color: #00FA9A; height: 15px; width: 15px;" onclick="color('#00FA9A')"></button>
                <td><button style="background-color: #00FF7F; height: 15px; width: 15px;" onclick="color('#00FF7F')"></button>
                <td><button style="background-color: #00C957; height: 15px; width: 15px;" onclick="color('#00C957')"></button>
                <td><button style="background-color: #FFFF00; height: 15px; width: 15px;" onclick="color('#FFFF00')"></button>
                <td><button style="background-color: #CDCD00; height: 15px; width: 15px;" onclick="color('#CDCD00')"></button>
                <td><button style="background-color: #FFF68F; height: 15px; width: 15px;" onclick="color('#FFF68F')"></button>
                <td><button style="background-color: #FFFACD; height: 15px; width: 15px;" onclick="color('#FFFACD')"></button>
                <td><button style="background-color: #FFEC8B; height: 15px; width: 15px;" onclick="color('#FFEC8B')"></button>
                <td><button style="background-color: #FFD700; height: 15px; width: 15px;" onclick="color('#FFD700')"></button>
                <td><button style="background-color: #F5DEB3; height: 15px; width: 15px;" onclick="color('#F5DEB3')"></button>
                <td><button style="background-color: #FFE4B5; height: 15px; width: 15px;" onclick="color('#FFE4B5')"></button>
                <td><button style="background-color: #EECFA1; height: 15px; width: 15px;" onclick="color('#EECFA1')"></button>
                <td><button style="background-color: #FF9912; height: 15px; width: 15px;" onclick="color('#FF9912')"></button>
                <td><button style="background-color: #8E388E; height: 15px; width: 15px;" onclick="color('#8E388E')"></button>
                <td><button style="background-color: #7171C6; height: 15px; width: 15px;" onclick="color('#7171C6')"></button>
                <td><button style="background-color: #7D9EC0; height: 15px; width: 15px;" onclick="color('#7D9EC0')"></button>
                <td><button style="background-color: #388E8E; height: 15px; width: 15px;" onclick="color('#388E8E')"></button>
                
            </tr>
            
            <tr>
                <td><button style="height: 18px; width: 80px" onclick="outline()">Outline</button>
                <td><button style="background-color: #71C671; height: 15px; width: 15px;" onclick="color('#71C671')"></button>
                <td><button style="background-color: #8E8E38; height: 15px; width: 15px;" onclick="color('#8E8E38')"></button>
                <td><button style="background-color: #C5C1AA; height: 15px; width: 15px;" onclick="color('#C5C1AA')"></button>
                <td><button style="background-color: #C67171; height: 15px; width: 15px;" onclick="color('#C67171')"></button>
                <td><button style="background-color: #555555; height: 15px; width: 15px;" onclick="color('#555555')"></button>
                <td><button style="background-color: #848484; height: 15px; width: 15px;" onclick="color('#848484')"></button>
                <td><button style="background-color: #F4F4F4; height: 15px; width: 15px;" onclick="color('#F4F4F4')"></button>
                <td><button style="background-color: #EE0000; height: 15px; width: 15px;" onclick="color('#EE0000')"></button>
                <td><button style="background-color: #FF4040; height: 15px; width: 15px;" onclick="color('#FF4040')"></button>
                <td><button style="background-color: #EE6363; height: 15px; width: 15px;" onclick="color('#EE6363')"></button>
                <td><button style="background-color: #FFC1C1; height: 15px; width: 15px;" onclick="color('#FFC1C1')"></button>
                <td><button style="background-color: #FF7256; height: 15px; width: 15px;" onclick="color('#FF7256')"></button>
                <td><button style="background-color: #FF4500; height: 15px; width: 15px;" onclick="color('#FF4500')"></button>
                <td><button style="background-color: #F4A460; height: 15px; width: 15px;" onclick="color('#F4A460')"></button>
                <td><button style="background-color: #FF8000; height: 15px; width: 15px;" onclick="color('FF8000')"></button>
                <td><button style="background-color: #FFD700; height: 15px; width: 15px;" onclick="color('#FFD700')"></button>
                <td><button style="background-color: #8B864E; height: 15px; width: 15px;" onclick="color('#8B864E')"></button>
                <td><button style="background-color: #9ACD32; height: 15px; width: 15px;" onclick="color('#9ACD32')"></button>
                <td><button style="background-color: #66CD00; height: 15px; width: 15px;" onclick="color('#66CD00')"></button>
                <td><button style="background-color: #BDFCC9; height: 15px; width: 15px;" onclick="color('#BDFCC9')"></button>
                <td><button style="background-color: #76EEC6; height: 15px; width: 15px;" onclick="color('#76EEC6')"></button>
                <td><button style="background-color: #40E0D0; height: 15px; width: 15px;" onclick="color('#40E0D0')"></button>
                <td><button style="background-color: #9B30FF; height: 15px; width: 15px;" onclick="color('#9B30FF')"></button>
                <td><button style="background-color: #EE82EE; height: 15px; width: 15px;" onclick="color('#EE82EE')"></button>
                <td><button style="background-color: #FFC0CB; height: 15px; width: 15px;" onclick="color('#FFC0CB')"></button>
                <td><button style="background-color: #7CFC00; height: 15px; width: 15px;" onclick="color('#7CFC00')"></button>
            </tr>
            <tr>
                <td><label>Line Width</label></td>
                <td><button id="pixel_plus" type="button" onclick="add_pixel()" style="width: 25px;">+</button></td>
                <td><button id="pixel_minus" type="button" onclick="reduce_pixel()" style="width: 25px;">-</button></td>
                <td><button id="undo" type="button" onclick="undo_pixel()"style="width: 75px;">Undo</button></td>

            </tr>
            </table>
            <br>
            <label>Tag</label><input id="fname" type="text"><button id="save" onclick="temp()">Add</button>
            <br>
            <br>
            </fieldset>

Update user information using react js and node js

I’d like to update the username and the email… the backend is working but the frontend is not updating,

I updated the username and the mail and when I see my update in the frontend, it’s the same nothing happend even though i got the alert “admin updated”, however when i test the backend there is no issue and it’s working .

the backend:

  app.put("/admin/:id", (req, res) => {
    LoginAdmin.findOneAndUpdate({_id: req.params.id},{
      $set:{
        email : req.body.email,
        adminname: req.body.adminname
      }
    }, function (err, data) {
      if (err){
        res.status(500).send(err)
    } else {
      res.status(200).send({message: 'UPDATED', data: data})
    }
    })
  })

the frontend:

const UpdateAdminAccount = (props) => {
    let navigate= useNavigate()
    const initialInputValues = {
      adminname: '',
      email: '',
    } 
    const [values, setValues] = useState(initialInputValues)

    //show admin info before updating
    const {id} = useParams()
    useEffect(()=>{
     if(id){
         getSingleAdmin(id)
     }
    },[id])
    const getSingleAdmin = async (id) =>{
        const response = await axios.get(`/admin/${id}`);
        console.log("response", response)
        if (response.status === 200){
            setValues(response.data);
        }
    };

      const handleInputChange = (e) => {
        const name = e.target.name
        const value = e.target.value
        setValues({
          ...values,
          [name]: value,
        })
      }   
 
      const updateAdmin = async (e, id) =>{
        e.preventDefault();
          await axios.put(`/admin/${id}`, {
          ...values
          }
          ).then((res) =>{    
            console.log(res)
              if (res.data.message === 'UPDATED') {
                  alert("admin updated")
                  }
            })   
    };
    return (
            <form method='Post'>
             <ul>
              <li>
                  <label>Name</label>
                  <input name="adminname" value={values.adminname} onChange={handleInputChange} type="text" />
              </li>
              <li> 
                  <label>Email</label>
                  <input name="email" value={values.email} onChange={handleInputChange} type="email"  />
             </li>
              <li>
              <li>
                   
                  <button className='submit-button' onClick={updateAdmin} type="submit" > 
                    Update
                  </button> :
                  
              </li>
             </ul>
            </form>
            </div>
  
        </div>  
      </div>
    );
}

export default UpdateAdminAccount;

vue3 setting css styles from vuex store

I am trying to update the value of my css property .page with the value from vuex store. I am able to do it via the value of data but not from the computed property.

    <script>
           export default {
            name: 'component',
            components: {
             

   Header,
            Footer
        },
        data(){
            return {
                color: '#f00'
            }
        },
    }
            
</script>
        
   <style>
        
        .page{
             background-color: v-bind(color);
        }
        
   </style>

above works, but below doesn’t.

<script>
   export default {
    name: 'component',
    components: {
        Header,
        Footer
    },
    branding() {
        return this.$store.state.branding.color;
        },
    }
            
 </script>
            
 <style>
            
     .page{
            background-color: v-bind(color);
     }
     

I’ve only got a basic understanding of vue so any help would be much appreciated

How to hide browser’s scrollbar when using locomotive-scroll in React?

I’ve been trying to use locomotive-scroll to add the smooth scrolling feature to my website. I got it up and running well, however while scrolling, I notice that the browser’s default scrollbar stays at the same place as the scrollbar from the locomotive-scroll. I tried to do everything to hide it but no success. Can anyone instruct me on this issue. Thank you. Here is the image of the scrollbar (the pink part is the locomotive’s scrollbar).

enter image description here

how to remove nav item on window resize?

I want target to prepent in more dropdown when screen size is below 1190px & remove target from dropdown when screen size is above 1190px

This is the outcome i want

I can make target disappear easily but target to appear in dropdown part is tricky. I’ve used window.onresize & window.onload with below condition

if (window.innerWidth < 1190 && window.innerWidth > 1188) { var dt = document.createElement("dt"); dt.innerHTML = 'Target'; dt.className = '.target' dl.prepend(dt); } if (window.innerWidth > 1189 && window.innerWidth < 1191) { console.log('done') dt?.remove() }

Date.getTime is not a constructor

In a function I have the line:

const currentTime = new Date.getTime();

The code compiles just fine.
Also, ESLint displays neither warnings or
errors.
But when I run the code, I get an alert box giving the confusing
message Date.getTime is not a constructor.

What is wrong here?

Error message: 'Date.getTime is not a constructor'


I have noticed that there is no error if I don’t call the function
that contains the line above.

The following Stack Snippet reproduces the error.

function rightNow() {
  const currentTime = new Date.getTime();
  return currentTime;
}
console.log(rightNow().toString());
// ^^ No error if I comment out the previous line! ^^
.as-console-wrapper { max-height: 100% !important; top: 0; }

Scroll to the top list item without scrolling the view – ReactJS

I want to scroll to an item in the list, but when I click on the item my entire view scrolls. I would like the scroll to be only for the div with the list.

<AlertsList>
        {productInventoryAlert?.map((product, index) => {
          const itemRef = createRef<HTMLLIElement>();

          const handleScrollIntoView = (index: number) => {
            if (expandedCard === index) {
              setExpandedCard(-1);
            } else {
              setExpandedCard(index);
            }

            itemRef.current?.scrollIntoView(true);
          }

          return (
            <li ref={itemRef} key={index}>
              <DashboardInventoryAlertListItem
                handleScrollIntoView={handleScrollIntoView}
                product={product}
                index={index}
                expandedCard={expandedCard}
              />
            </li>
          );
        })}
</AlertsList>

export const AlertsList = styled.ul`
  max-height: 250px;
  overflow: scroll;
  list-style: none;
  scroll-behavior: smooth;
 `;

How to make parameters change in an equation in a function when calling it?

I want to create a function that can generate two balls that rise at different speeds. I used the parameters of the speed in which it rises called “change” and another parameter of its x coordinates called “x”, so that they don’t originate from the same place.

If I call the function, it works, and the ball moves according to the speed I set it to. However, if I call it twice, two balls are generated but both move at the speed that I call it with the second time. In this case, two balls were generated at x coordinates 150 and 450. The first ball was supposed to move at speed y-10, and the second ball at speed y-5, but both are moving at y-5.

Therefore, they move, but the whole purpose of the code which is making it change doesn’t work. Can someone help me make it change?

void setup(){
  size(600,600);
}
float y = 600;

 void risingball(float change, float x){
  noStroke();
  fill(30,0,30);
  y = y-change;
  ellipse(x,y, 50,50);
}
  void draw(){
  background(255);
  risingball(10, 450);
  risingball(5, 250);
}

Chartjs not giving ‘xLabel’ properly on tooltip

I have a line chart where data is displayed as point elements depending on the X axes (time axis) label.

enter image description here

    // Config chart
    const config = {
      type: "line",
      data: {
            labels: ['ene.', 'feb', 'mar.', 'abr.', 'may.', 'jun.', 'jul.', 'ago.', 'sep.', 'oct.', 'nov.', 'dic.'],
            datasets // ex --> [{ x: 'jun.', y: 90 }]
        },
      options: {
            tooltips: {
                callbacks: {
                    title: function(context) {
                             console.log(context); // Returning wrong xLabel 
                           }
                }
            }
      }
    }

The problem is when it shows the tooltip of, for example, June it takes it as index 3 so the title tooltip (xlabel) is shown as “April”.

enter image description here

How could I get the proper label on the tooltip, not depending on the index?