Hello there i am newbie on java script. I get problem when i want to save data moralis db.
import { Box, Input, Text, Heading, Stack, Button, Spacer, Textarea, FormControl, FormLabel, Select, NumberInput, NumberInputField, NumberInputStepper, NumberIncrementStepper, NumberDecrementStepper } from '@chakra-ui/react'
import { useState } from 'react'
import { useMoralis, useMoralisQuery,useMoralisSubscription } from 'react-moralis'
import { ErrorBox } from './Error';
import { Moralis } from "moralis";
import axios from 'axios';
const TOURNAMENTS_COLLECTION_NAME = 'Tournaments';
export const CreateTournaments = () => {
const { data, error, isLoading } = useMoralisQuery("Tournaments");
const [maxScore, setMaxScore] = useState(100);
const [limit, setLimit] = useState(3);
const { user, setUserData, userError, isUserUpdating, logout } = useMoralis();
const [username, setUsername] = useState(user.attributes.username);
const [email, setEmail] = useState(user.attributes.email);
const [password, setPassword] = useState(user.attributes.password);
const Tournaments = Moralis.Object.extend("Tournaments");
const tournaments = Tournaments();
const handleAddTournaments = () => {
tournaments.save({
score: 1337,
playerName: "Sean Plott",
cheatMode: false
})
.then((tournaments) => {
// The object was saved successfully.
console.log(tournaments)
}, (error) => {
// The save failed.
// error is a Moralis.Error with an error code and message.
console.log("error")
});
}
const handleSave = () => {
setUserData({
username,
email,
password: password === "" ? undefined : password
})
}
return (
<Box>
{JSON.stringify(data, null, 2)}
<Stack my={3}>
<Heading>Create Tournaments</Heading>
</Stack>
<Box>
<FormLabel>Featured Image</FormLabel>
<Input type="file" />
</Box>
<Stack spacing={3}>
<Box>
<FormControl id="country">
<FormLabel>Chose Game</FormLabel>
<Select placeholder="Select country">
<option>Mobile Legends</option>
<option>Pubg</option>
<option>Apex</option>
<option>PES</option>
</Select>
</FormControl>
</Box>
<Box>
<FormLabel>Title</FormLabel>
<Input />
</Box>
<Box>
<FormLabel>Descriptions</FormLabel>
<Textarea />
</Box>
<Box>
<FormControl id="amount">
<FormLabel>Cost per slot</FormLabel>
<NumberInput max={50} min={1}>
<NumberInputField />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
</FormControl>
</Box>
<Button onClick={() => handleAddTournaments()}>Create Now</Button>
</Stack>
</Box>
)
}
here is the error