API update

This commit is contained in:
LixayTF 2023-09-20 15:38:00 +02:00
parent 4ff17da8c5
commit 1e46c9e342

View File

@ -1,5 +1,6 @@
import './App.css';
import { useState } from 'react';
import axios from 'axios';
function App() {
const [datasetQuarry, setDatasetQuarry] = useState('');
@ -7,10 +8,23 @@ function App() {
const [columns, setColumns] = useState('');
const [results, setResults] = useState('');
const handleButtonClick = () => {
const fetchDataFromAPI = async (dataset, table, column) => {
try {
const response = await axios.get(`YOUR_API_ENDPOINT?dataset=${dataset}&table=${table}&column=${column}`);
const data = response.data;
setResults('Tutaj możesz umieścić swoje wyniki.');
setResults(data);
} catch (error) {
console.error('Error fetching data:', error);
setResults('Error fetching data');
}
};
const handleButtonClick = () => {
// Call the API request function with the provided parameters
fetchDataFromAPI(datasetQuarry, tableQuarry, columns);
};
return (
<div className="container">
<div className="row">
@ -40,34 +54,17 @@ function App() {
</div>
<div className="row">
<button type="button" onClick={handleButtonClick}>
Przycisk
Test
</button>
</div>
<div className="row">
<textarea
placeholder="Resoults"
placeholder="Results"
value={results}
onChange={(e) => setResults(e.target.value)}
></textarea>
</div>
</div>
// <div className="container">
// <header className="App-header">
// <img src={logo} className="App-logo" alt="logo" />
// <p>
// Edit <code>src/App.js</code> and save to reload.
// </p>
// <a
// className="App-link"
// href="https://reactjs.org"
// target="_blank"
// rel="noopener noreferrer"
// >
// Learn React
// </a>
// </header>
// </div>
);
}