get
1
2
3
4
5
const onClick = () => {
axios.get("url").then((response) => {
setData(response.data);
});
};
async
1
2
3
4
5
6
7
8
9
const onClick = async () => {
try {
const response = await axios.get(
'url',
);
setData(response.data);
} catch (e) {
console.log(e);
}