From c0e1c9332d4c376a83aeb4181a86c7d747cab69b Mon Sep 17 00:00:00 2001 From: shanyuhai123 <864299347@qq.com> Date: Mon, 15 Jun 2020 22:52:01 +0800 Subject: [PATCH] update: writeFile changed to writeFileSync --- snippets/JSONToFile.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/JSONToFile.md b/snippets/JSONToFile.md index 71f063108..444efe0b8 100644 --- a/snippets/JSONToFile.md +++ b/snippets/JSONToFile.md @@ -5,12 +5,12 @@ tags: node,json,intermediate Writes a JSON object to a file. -Use `fs.writeFile()`, template literals and `JSON.stringify()` to write a `json` object to a `.json` file. +Use `fs.writeFileSync()`, template literals and `JSON.stringify()` to write a `json` object to a `.json` file. ```js const fs = require('fs'); const JSONToFile = (obj, filename) => - fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); + fs.writeFileSync(`${filename}.json`, JSON.stringify(obj, null, 2)); ``` ```js