'How to set mydata to axios GET data?
I want to send lists(in Content) to mainData and then in mainData I want to set the lists to respone.data (so lists(in Content) is set to response.data) HOW CAN I DO IT ?? please help me... :(
// Content. js
const Content = (props) => {
const [lists, setLists] = useState(null);
useEffect(() => {
mainData(setLists, props.url);
}, []);
// mainData.js
import axios from 'axios';
export const mainData = async({setLists, url}) => {
try {
setLists(null);
const response = await axios.get(url);
setLists(response.data);
} catch(error) {
console.error(error);
}
}
Solution 1:[1]
A GET request is not designed to upload data. You need to make a POST request, and set the {data: "something"} option in the request config for that to work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Skipper |
