I have file users.json and i have to save it
Standard methods doesn’t work like using fs
How do i save my json file (pls write a code)
Ik that by typing “refresh” in console i can save it but i need it in code
What do you mean by save? Download it to your computer? Does copying and pasting get the job done?
const fs = require('fs');
fs.writeFileSync('demofile.json', JSON.stringify({hello:'world'}));
i use this in my projects, try it
I meant load data from file then change and save it back. .json file is located on glitch
Like editing the file?
Yes. I need to save users datas and edit it when smth changes
Glitch autosaves.
How often does it saves?
whoopsie, didn’t know what u meant
Should be whenever you edit.
I think OP is just talking about the editor.
oh sorry rocks
It isnt works or i make sth wrong
I just declarate var and save file in it
Then i use fs to save file but it isnt saves
You are editing the file from the online editor, right? Or are you editing the file from your code?
From my code
Oh, ok, can you share your code/project so I can have a look?
Anything in your logs?
No, nothing about it
I’m not a node expert, but the standard way to use fs is to declare it at the top of the script:
const fs = require('fs')
My code perfectly works on repl.it but i need free 24/7 hosting
Sorry, but Glitch doesn’t support free 24/7 hosting.
Ive found information that it does
It no longer does, sorry.
Ok so i will try to find new hosts
Bye, and sorry for wasting your time
Oh, you didn’t waste my time. Best of luck.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.