Search code examples
node.jssqliteexpressknex.js

"TypeError: Converting circular structure to JSON" with GET request


I get this error when I try a GET request on "/strutture" trough Insomnia:

TypeError: Converting circular structure to JSON

Here's the repo (inside the server folder I'm getting the error, I still need to merge it with the React app). I noticed when doing the migration, no ".db3" file got created.


Solution

  • You can just use promise fulfilment to get the results.

    server.get('/strutture', async (req, res) => {
        //GET STRUTTURE
        try{
            const strutture = await db("structure");
            res.json(strutture);
        } catch(err){
            console.log(err);
        }
    })
    

    This will return the correct query results

    query result of knex