I
I
Ivan2021-12-16 15:04:03
JavaScript
Ivan, 2021-12-16 15:04:03

Why is the data not being written to the file?

Hello! Please help me figure out why it is not possible to write data to the file.
The data.json file is in the same folder as the script.
The console gives a null response.
Why does not write down, I'll never know.

const fs = require("fs-extra");
fs.outputJson("./data.json", {name: 'JP'}, err => console.log(err))


data.json
[
  {
    "input": "абвгдеёжзийклмнопрстуфхцчшщъыьэюя",
    "output": "normal"
  },
  {
    "input": "абвгдеёжзийклмнопрстуфхцчшщъыьэюя",
    "output": "normal"
  }
]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2021-12-16
@skapunker

In general, I figured it out. The function works, the problem was in the file path.

A
Alex_mos, 2021-12-16
@Alex_mos

Here there is an example that returns null and which, apparently, write data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question