K
K
Klucva2022-02-02 21:15:13
Node.js
Klucva, 2022-02-02 21:15:13

Why does nodejs fs.writeFileSync write buffer to file?

I have an object and I want to write it to a file, for this I use:

fs.writeFileSync("./profiles/"+new_user_id+"/user_info.json", JSON.stringify(new_user), 'utf8');

This works with short objects, but if the object is long, then the following is written to the file:
{"type":"Buffer","data"[91,111,...,116,93]}
Why does this happen and how can I fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question