Json file not updated

I’m tring to update a .json file using this code:

const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('db.json')
const db = low(adapter)
var database = require("./db.json");

db.set('count', database.count+1)
  .write()

the problem is its keep the data but only after I do refresh in the console.
is there a way to make it refresh the editor after I run the code?

Hey @sbh1311 right now Glitch doesn’t sync automatically between the backend and the Editor, so a manual refresh is the best you can hope for. You could use something like Node’s child_process to run the refresh after your update is complete though.

Hope this helps!

kinda thanks!
I will try to use Node’s child_process

1 Like