W
W
wufapexef2017-10-06 18:27:54
Node.js
wufapexef, 2017-10-06 18:27:54

How to request a file and create it if it doesn't exist?

There is such a line The problem is that this file does not always exist. So Noda throws an error and dies. How to build an application in this case? Use not require but fs? How can I do this with fs, given that I need to return data from this JSON file after it is created?
const snapshot = require(`./${file}`)

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