ADD
const [text, setText] = useState<string>("");
let id = 0;
interface newListType {
id: number;
text: string;
isDone: boolean;
}
const addLists = async (el: any) => {
el.preventDefault();
const newList: newListType = {
id: id++,
text,
isDone: false,
};
await axios.post("http://localhost:3010/List", newList);
setText("");
};
GET
const [list, setList] = useState<any>([]);
const getList = async () => {
const Lists = await axios.get("http://localhost:3010/List");
setList(Lists.data);
};
useEffect(() => {
getList();
}, []);