Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
In react js How to fetch the variable which is in inside a function in class coponent?

I need to fetch the variable which is inside a function in class component. This is my function I want to fetch the "newArray" variable in class component.

handleChanges(event) { 
          this.setState({value: event.target.value}); 
          console.log("value",event.target.value);
         
          let values=['OurStory','HowItWorks','Blog','Login','BeaParopakari'];
          console.log("values",values);
          let url =
          "http://localhost:49590/api/Authenticate/Translate?values=xxxxxxxxxxxxxxx";
          let user = JSON.parse(localStorage.getItem("user"));
          const accessToken = user;
          console.log(accessToken);
          fetch(url, {
            method: "GET",
            headers: {
              "Content-type": "application/json",
              Accept: "application/json",
              Authorization: "Bearer " + accessToken,
              "Access-Control-Allow-Headers": "Access-Control-Request-Headers "
            }
          })
          .then((response) => response.json())
          .then((data) => {
             this.setState({    
               Details: data
             });
            console.log("Filter", data);
            const longArray = data;
            const size = 1;
            
            const newArray = new Array(Math.ceil(longArray.length / size)).fill("")
                .map(function() { return this.splice(0, size) }, longArray.slice());

               

                console.log(this.state.newArray);
                const trans = "Vijayaasri";
              
          });

I tried it in state but it didn't work.

{this.state.newArray.map(s=>s.result)}

I use map function to fetch.

enter image description here

This newArray value I need to print in page. Please share your knowledge. Thank You in Advance.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!