Problems with JSON

Hey, I have problems with saving data to JSON, Glitch randomly wipes data from JSON and removes everything from it :confused: How can I solve it ?

Are you saving data to a .json file, or just to a variable in your project? If you let us know your project name, we can take a look.

I’m saving variable to from project to JSON object, project name is pixelbot-v1 (You’re already in), problem is with startPixel() method in index.js

Ok, so you’re reading and writing data to and from a file and the syntax of that looks ok. My hunch is that it’s a problem with the timings of when you’re reading/writing to the file because you have multiple nested setInterval and setTimeout functions and any project restarts, like when you’re working on the code could interrupt that too.

I recommend looking at using something like low-db (https://glitch.com/~low-db), which uses JSON files on the filesystem as a simple database. It will allow you more control over manipulating the content of the file such that you won’t accidentally overwrite your data.

1 Like

Question, how can I remove object from lowdb

Docs are here: https://github.com/typicode/lowdb - you can see a couple of options for removing data.

Thank you Gareth!

It works with LowDB, thank you for fast answer and solution, thanks for helping always :stuck_out_tongue:

Best regards from Poland, John :wink:

1 Like