Skip to content

Instantly share code, notes, and snippets.

@Josh4324
Last active November 24, 2020 09:46
Show Gist options
  • Save Josh4324/eb59c7a6b7b0825fe4a51c3e19af0b70 to your computer and use it in GitHub Desktop.
Save Josh4324/eb59c7a6b7b0825fe4a51c3e19af0b70 to your computer and use it in GitHub Desktop.
const listTodo = () => {
try {
// read from the todos.json if it exists
const todoBuffer = fs.readFileSync("todos.json");
// convert it to string
let dataJSON = todoBuffer.toString();
// parse the data
const todos = JSON.parse(dataJSON);
console.log(todos)
}catch(error){
console.log("An error occured")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment