Skip to content

Instantly share code, notes, and snippets.

@Josh4324
Last active November 24, 2020 09:44
Show Gist options
  • Save Josh4324/f1fd695558dd458e978e99a5f2feb64d to your computer and use it in GitHub Desktop.
Save Josh4324/f1fd695558dd458e978e99a5f2feb64d to your computer and use it in GitHub Desktop.
Get One Todo
const getOneTodo = (title) => {
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);
const Todo = todos.find((item) => {
return item.title === title;
})
console.log(Todo);
}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