Here's an example of how to use the outputJson
function from fs-extra
to write a JavaScript object to a JSON file:
index.tsx208 chars8 lines
In this example, we're passing the outputJson
function two arguments:
'path/to/myfile.json'
)myObject
)The outputJson
function returns a promise, so we can use .then
and .catch
to handle success and error scenarios, respectively. In the success case, we're logging a message to the console, and in the error case, we're logging the error object to the console.
gistlibby LogSnag