How to add an object from one table to another table as a STRING

Viewed 26

I am using React.js, sequeliza and MariaDB for a web application.

I want to use a findAll function to get a list of options from one table and be able to choose one to add to the other table. When i do this I get a 'string violation' error.

Is there a way of turning the object into a string or some other way of adding the object from the first table to the other table?

Heres my react code:


    <FormControl sx={{marginBottom: "2%", background: "#FFF", marginRight: "2%" }}>
        <InputLabel id="demo-simple-select label">Header</InputLabel>
            <Select
                labelId="demo-simple-select-label"
                id="demo-simple-select"
                value={vision}
                label="Header"
                onChange={(e) => setVision(e.target.value)}
                >
                    {visions.map((c) => (
                        <MenuItem key={c} value={c}>
                            {c.name}
                        </MenuItem>
                    ))}
          </Select>
    </FormControl>

Here is the get function from the database:

async function getVisions()
{
    const fetchedVisions = await ModelService.findAll("Vision", {});

    const fetchedVision = fetchedVisions
    .map((response) => response.data);
    setVisions(fetchedVision);
}
0 Answers
Related