Answer the question
In order to leave comments, you need to log in
Add element to json (Node.js)?
Hello.
In the node.js script, you need to make sure that users.json is added:
{
"user#1111":{
"coins": 100
"steam_account": "steam11111"
"socialclub": "user111111"
}
}
Answer the question
In order to leave comments, you need to log in
as I understand it, you have an array of users in the users.json file,
if you connect it via const users = require("users.json") you will have a js object in the variable,
in your case an array of users, then you do users.push(user)
then write json through fs writeFile (don't forget to serialize the object through JSON.stringify(users)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question