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

102
Views
Call api on page load in React

I am learning React and I am trying to call an API on my page load, but I haven't had much success so far. I am trying to call an API which will pull an JSON that is used to fill my grid. Here is my code:


import React, { Component, useCallback, useState, useEffect } from "react";
import axios from 'axios';


import './styles.css';
import '@progress/kendo-theme-default/dist/all.css';
import { Grid, GridColumn, GridToolbar } from "@progress/kendo-react-grid";
import { DropDownList } from "@progress/kendo-react-dropdowns";
import { GridPDFExport } from "@progress/kendo-react-pdf";
import { ExcelExport } from "@progress/kendo-react-excel-export";

export function GridTable1({}) {
  
  const [ grid1, setGrid1 ] = useState();

  const fillTable= async () => {
     await  axios
          .get('http://11.11.21.111:8888/api/v1/CheckTablespace')
          .then((res) => {
            setGrid1(res.rlista)
          });
          console.log('Log this');
      }

     
      useEffect(() => {
        
        fillTable();
      }, [])
 
    return (
...
...
  );
}


The console log isn't logged, so I don't know what to do. Help would be very much appreciated

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this!!!

export function GridTable1() {
      const [ grid1, setGrid1 ] = useState();
    
  useEffect(() => {
         axios
          .get('http://11.11.21.111:8888/api/v1/CheckTablespace')
          .then((res) => {
            setGrid1(res.rlista)
          });
          console.log('Log this');
  }, []);

  return (
{grid1 &&
    <div>
     ...your HTML
    </div>}
  );
}
about 4 years ago · Juan Pablo Isaza Report
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!