Show server response using react

I’m trying to create a web page where, through a button, the host makes a call (locally) on an api rest in a backend server. Up to here everything is ok. I would then like to show some information answered by the server under the button, and I can’t do it. Could someone help me? Thank you

ps. this is my first time using react

this is my react code:

import React, { Component } from 'react';
import {useState} from 'react';
import ReactDOM, { unmountComponentAtNode } from 'react-dom';
import './index.css';
import reportWebVitals from './reportWebVitals';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import axios from 'axios';
import { render } from '@testing-library/react';



function SetResponse(){
  const [respons,setRespons] = useState('');
}



const useStyles = makeStyles((theme) => ({
  root: {
    '& > *': {
      margin: theme.spacing(1),
    },
  },
}));

function OutlinedButtons() {
  const classes = useStyles();
  
  return (

    <div style={{display: 'flex',  justifyContent:'center', alignItems:'center', height: '100vh'}}>
      <Button  onClick={()=>Clicked()} variant="outlined" size="large" className={classes.button} color="primary" href="#outlined-buttons">
        Work for me,
        NOW!
      </Button>
    {respons}
      </div>

  );
  }

function Clicked(){


  try {
    axios.post ('http://192.168.99.100:8081/api/v1/processes',{}).then(function (response) {
      console.log(response.data);
      console.log(response.status);
      console.log(response.statusText);
      console.log(response.headers);
      console.log(response.config);
  });
  setRespons(response.status);

    
  }catch (error) {
    console.log(error);
  }
}

function Show(){
  return(
    <div>
      <OutlinedButtons />
    </div>
  )
}


ReactDOM.render(
  <React.StrictMode>
    <Show />
  </React.StrictMode>,
  document.getElementById('root')
);
reportWebVitals();

Answer

i see some problems in your code, first the response is outside of the axios method, the setRespons is inside of a method that you don’t use for anything. perhaps you can see this example that i made base on your code, maybe this help you to understand better

https://codesandbox.io/s/simpleaxios-c0k1d