{"action":"created","comment":{"url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/comments/219683078","pull_request_review_id":157923031,"id":219683078,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxOTY4MzA3OA==","diff_hunk":"@@ -0,0 +1,91 @@\n+'use strict';\n+\n+const fs = require('fs');\n+const storage = './todos.json';\n+\n+function runTheFunction(func, param1, param2) {","path":"week3/homework/src/manipulate.js","position":6,"original_position":6,"commit_id":"383ed938803748cb3bba1fff8f99161551ebfcfd","original_commit_id":"383ed938803748cb3bba1fff8f99161551ebfcfd","user":{"login":"J05J4","id":1948641,"node_id":"MDQ6VXNlcjE5NDg2NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/1948641?v=4","gravatar_id":"","url":"https://api.github.com/users/J05J4","html_url":"https://github.com/J05J4","followers_url":"https://api.github.com/users/J05J4/followers","following_url":"https://api.github.com/users/J05J4/following{/other_user}","gists_url":"https://api.github.com/users/J05J4/gists{/gist_id}","starred_url":"https://api.github.com/users/J05J4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/J05J4/subscriptions","organizations_url":"https://api.github.com/users/J05J4/orgs","repos_url":"https://api.github.com/users/J05J4/repos","events_url":"https://api.github.com/users/J05J4/events{/privacy}","received_events_url":"https://api.github.com/users/J05J4/received_events","type":"User","site_admin":false},"body":"You can refactor this into `readData()` function, that only reads the data and returns it as JSON.\r\nYou can then call that function from for example an `add(item)` function (and all other functions):\r\n```\r\nfunction add(item) {\r\n    const data = readData();\r\n    const itemObj = {\r\n        index: toDoList.length + 1,\r\n        description: item\r\n    };\r\n    toDoList.push(itemObj);\r\n\r\n    fs.writeFile(storage, JSON.stringify(toDoList), (error) => {\r\n        if (error) { console.log(error); }\r\n    });\r\n}\r\n```\r\nIn that way you can call the `add(item)` function directly from your route, so you would have in `src/index.js`:\r\n```\r\napp.post('todos, (request, response) => {\r\n    manipulate.add(request.body.task);\r\n    response\r\n        .status(201)\r\n        .json({ result: \"your task is added!\" });\r\n});\r\n```","created_at":"2018-09-22T21:52:30Z","updated_at":"2018-09-22T21:59:03Z","html_url":"https://github.com/HackYourFuture/Node.js/pull/246#discussion_r219683078","pull_request_url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/comments/219683078"},"html":{"href":"https://github.com/HackYourFuture/Node.js/pull/246#discussion_r219683078"},"pull_request":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246"}}},"pull_request":{"url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246","id":216084045,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2MDg0MDQ1","html_url":"https://github.com/HackYourFuture/Node.js/pull/246","diff_url":"https://github.com/HackYourFuture/Node.js/pull/246.diff","patch_url":"https://github.com/HackYourFuture/Node.js/pull/246.patch","issue_url":"https://api.github.com/repos/HackYourFuture/Node.js/issues/246","number":246,"state":"open","locked":false,"title":"Node week3","user":{"login":"mehmetscoskun","id":39768263,"node_id":"MDQ6VXNlcjM5NzY4MjYz","avatar_url":"https://avatars3.githubusercontent.com/u/39768263?v=4","gravatar_id":"","url":"https://api.github.com/users/mehmetscoskun","html_url":"https://github.com/mehmetscoskun","followers_url":"https://api.github.com/users/mehmetscoskun/followers","following_url":"https://api.github.com/users/mehmetscoskun/following{/other_user}","gists_url":"https://api.github.com/users/mehmetscoskun/gists{/gist_id}","starred_url":"https://api.github.com/users/mehmetscoskun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mehmetscoskun/subscriptions","organizations_url":"https://api.github.com/users/mehmetscoskun/orgs","repos_url":"https://api.github.com/users/mehmetscoskun/repos","events_url":"https://api.github.com/users/mehmetscoskun/events{/privacy}","received_events_url":"https://api.github.com/users/mehmetscoskun/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-09-17T19:09:20Z","updated_at":"2018-09-22T21:59:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aa4cfdeee24a52bfc5ff33bd0155a94b2151ee2f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1052715631,"node_id":"MDU6TGFiZWwxMDUyNzE1NjMx","url":"https://api.github.com/repos/HackYourFuture/Node.js/labels/class%2016","name":"class 16","color":"0052cc","default":false},{"id":883891913,"node_id":"MDU6TGFiZWw4ODM4OTE5MTM=","url":"https://api.github.com/repos/HackYourFuture/Node.js/labels/homework3","name":"homework3","color":"0bead8","default":false},{"id":862630052,"node_id":"MDU6TGFiZWw4NjI2MzAwNTI=","url":"https://api.github.com/repos/HackYourFuture/Node.js/labels/to%20review","name":"to review","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246/commits","review_comments_url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246/comments","review_comment_url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HackYourFuture/Node.js/issues/246/comments","statuses_url":"https://api.github.com/repos/HackYourFuture/Node.js/statuses/383ed938803748cb3bba1fff8f99161551ebfcfd","head":{"label":"mehmetscoskun:node-week3","ref":"node-week3","sha":"383ed938803748cb3bba1fff8f99161551ebfcfd","user":{"login":"mehmetscoskun","id":39768263,"node_id":"MDQ6VXNlcjM5NzY4MjYz","avatar_url":"https://avatars3.githubusercontent.com/u/39768263?v=4","gravatar_id":"","url":"https://api.github.com/users/mehmetscoskun","html_url":"https://github.com/mehmetscoskun","followers_url":"https://api.github.com/users/mehmetscoskun/followers","following_url":"https://api.github.com/users/mehmetscoskun/following{/other_user}","gists_url":"https://api.github.com/users/mehmetscoskun/gists{/gist_id}","starred_url":"https://api.github.com/users/mehmetscoskun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mehmetscoskun/subscriptions","organizations_url":"https://api.github.com/users/mehmetscoskun/orgs","repos_url":"https://api.github.com/users/mehmetscoskun/repos","events_url":"https://api.github.com/users/mehmetscoskun/events{/privacy}","received_events_url":"https://api.github.com/users/mehmetscoskun/received_events","type":"User","site_admin":false},"repo":{"id":147248395,"node_id":"MDEwOlJlcG9zaXRvcnkxNDcyNDgzOTU=","name":"Node.js","full_name":"mehmetscoskun/Node.js","private":false,"owner":{"login":"mehmetscoskun","id":39768263,"node_id":"MDQ6VXNlcjM5NzY4MjYz","avatar_url":"https://avatars3.githubusercontent.com/u/39768263?v=4","gravatar_id":"","url":"https://api.github.com/users/mehmetscoskun","html_url":"https://github.com/mehmetscoskun","followers_url":"https://api.github.com/users/mehmetscoskun/followers","following_url":"https://api.github.com/users/mehmetscoskun/following{/other_user}","gists_url":"https://api.github.com/users/mehmetscoskun/gists{/gist_id}","starred_url":"https://api.github.com/users/mehmetscoskun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mehmetscoskun/subscriptions","organizations_url":"https://api.github.com/users/mehmetscoskun/orgs","repos_url":"https://api.github.com/users/mehmetscoskun/repos","events_url":"https://api.github.com/users/mehmetscoskun/events{/privacy}","received_events_url":"https://api.github.com/users/mehmetscoskun/received_events","type":"User","site_admin":false},"html_url":"https://github.com/mehmetscoskun/Node.js","description":"HackYourFuture - Node.js","fork":true,"url":"https://api.github.com/repos/mehmetscoskun/Node.js","forks_url":"https://api.github.com/repos/mehmetscoskun/Node.js/forks","keys_url":"https://api.github.com/repos/mehmetscoskun/Node.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mehmetscoskun/Node.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mehmetscoskun/Node.js/teams","hooks_url":"https://api.github.com/repos/mehmetscoskun/Node.js/hooks","issue_events_url":"https://api.github.com/repos/mehmetscoskun/Node.js/issues/events{/number}","events_url":"https://api.github.com/repos/mehmetscoskun/Node.js/events","assignees_url":"https://api.github.com/repos/mehmetscoskun/Node.js/assignees{/user}","branches_url":"https://api.github.com/repos/mehmetscoskun/Node.js/branches{/branch}","tags_url":"https://api.github.com/repos/mehmetscoskun/Node.js/tags","blobs_url":"https://api.github.com/repos/mehmetscoskun/Node.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mehmetscoskun/Node.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mehmetscoskun/Node.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/mehmetscoskun/Node.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mehmetscoskun/Node.js/statuses/{sha}","languages_url":"https://api.github.com/repos/mehmetscoskun/Node.js/languages","stargazers_url":"https://api.github.com/repos/mehmetscoskun/Node.js/stargazers","contributors_url":"https://api.github.com/repos/mehmetscoskun/Node.js/contributors","subscribers_url":"https://api.github.com/repos/mehmetscoskun/Node.js/subscribers","subscription_url":"https://api.github.com/repos/mehmetscoskun/Node.js/subscription","commits_url":"https://api.github.com/repos/mehmetscoskun/Node.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/mehmetscoskun/Node.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/mehmetscoskun/Node.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/mehmetscoskun/Node.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/mehmetscoskun/Node.js/contents/{+path}","compare_url":"https://api.github.com/repos/mehmetscoskun/Node.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mehmetscoskun/Node.js/merges","archive_url":"https://api.github.com/repos/mehmetscoskun/Node.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mehmetscoskun/Node.js/downloads","issues_url":"https://api.github.com/repos/mehmetscoskun/Node.js/issues{/number}","pulls_url":"https://api.github.com/repos/mehmetscoskun/Node.js/pulls{/number}","milestones_url":"https://api.github.com/repos/mehmetscoskun/Node.js/milestones{/number}","notifications_url":"https://api.github.com/repos/mehmetscoskun/Node.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mehmetscoskun/Node.js/labels{/name}","releases_url":"https://api.github.com/repos/mehmetscoskun/Node.js/releases{/id}","deployments_url":"https://api.github.com/repos/mehmetscoskun/Node.js/deployments","created_at":"2018-09-03T20:04:13Z","updated_at":"2018-09-03T20:04:15Z","pushed_at":"2018-09-21T13:59:51Z","git_url":"git://github.com/mehmetscoskun/Node.js.git","ssh_url":"git@github.com:mehmetscoskun/Node.js.git","clone_url":"https://github.com/mehmetscoskun/Node.js.git","svn_url":"https://github.com/mehmetscoskun/Node.js","homepage":"","size":709,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"HackYourFuture:master","ref":"master","sha":"948e655329a5085fe693cc3e8e6c4505428dfd19","user":{"login":"HackYourFuture","id":20858568,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwODU4NTY4","avatar_url":"https://avatars2.githubusercontent.com/u/20858568?v=4","gravatar_id":"","url":"https://api.github.com/users/HackYourFuture","html_url":"https://github.com/HackYourFuture","followers_url":"https://api.github.com/users/HackYourFuture/followers","following_url":"https://api.github.com/users/HackYourFuture/following{/other_user}","gists_url":"https://api.github.com/users/HackYourFuture/gists{/gist_id}","starred_url":"https://api.github.com/users/HackYourFuture/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackYourFuture/subscriptions","organizations_url":"https://api.github.com/users/HackYourFuture/orgs","repos_url":"https://api.github.com/users/HackYourFuture/repos","events_url":"https://api.github.com/users/HackYourFuture/events{/privacy}","received_events_url":"https://api.github.com/users/HackYourFuture/received_events","type":"Organization","site_admin":false},"repo":{"id":68906713,"node_id":"MDEwOlJlcG9zaXRvcnk2ODkwNjcxMw==","name":"Node.js","full_name":"HackYourFuture/Node.js","private":false,"owner":{"login":"HackYourFuture","id":20858568,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwODU4NTY4","avatar_url":"https://avatars2.githubusercontent.com/u/20858568?v=4","gravatar_id":"","url":"https://api.github.com/users/HackYourFuture","html_url":"https://github.com/HackYourFuture","followers_url":"https://api.github.com/users/HackYourFuture/followers","following_url":"https://api.github.com/users/HackYourFuture/following{/other_user}","gists_url":"https://api.github.com/users/HackYourFuture/gists{/gist_id}","starred_url":"https://api.github.com/users/HackYourFuture/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackYourFuture/subscriptions","organizations_url":"https://api.github.com/users/HackYourFuture/orgs","repos_url":"https://api.github.com/users/HackYourFuture/repos","events_url":"https://api.github.com/users/HackYourFuture/events{/privacy}","received_events_url":"https://api.github.com/users/HackYourFuture/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/HackYourFuture/Node.js","description":"HackYourFuture - Node.js","fork":false,"url":"https://api.github.com/repos/HackYourFuture/Node.js","forks_url":"https://api.github.com/repos/HackYourFuture/Node.js/forks","keys_url":"https://api.github.com/repos/HackYourFuture/Node.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HackYourFuture/Node.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HackYourFuture/Node.js/teams","hooks_url":"https://api.github.com/repos/HackYourFuture/Node.js/hooks","issue_events_url":"https://api.github.com/repos/HackYourFuture/Node.js/issues/events{/number}","events_url":"https://api.github.com/repos/HackYourFuture/Node.js/events","assignees_url":"https://api.github.com/repos/HackYourFuture/Node.js/assignees{/user}","branches_url":"https://api.github.com/repos/HackYourFuture/Node.js/branches{/branch}","tags_url":"https://api.github.com/repos/HackYourFuture/Node.js/tags","blobs_url":"https://api.github.com/repos/HackYourFuture/Node.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HackYourFuture/Node.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HackYourFuture/Node.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/HackYourFuture/Node.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HackYourFuture/Node.js/statuses/{sha}","languages_url":"https://api.github.com/repos/HackYourFuture/Node.js/languages","stargazers_url":"https://api.github.com/repos/HackYourFuture/Node.js/stargazers","contributors_url":"https://api.github.com/repos/HackYourFuture/Node.js/contributors","subscribers_url":"https://api.github.com/repos/HackYourFuture/Node.js/subscribers","subscription_url":"https://api.github.com/repos/HackYourFuture/Node.js/subscription","commits_url":"https://api.github.com/repos/HackYourFuture/Node.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/HackYourFuture/Node.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/HackYourFuture/Node.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/HackYourFuture/Node.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/HackYourFuture/Node.js/contents/{+path}","compare_url":"https://api.github.com/repos/HackYourFuture/Node.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HackYourFuture/Node.js/merges","archive_url":"https://api.github.com/repos/HackYourFuture/Node.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HackYourFuture/Node.js/downloads","issues_url":"https://api.github.com/repos/HackYourFuture/Node.js/issues{/number}","pulls_url":"https://api.github.com/repos/HackYourFuture/Node.js/pulls{/number}","milestones_url":"https://api.github.com/repos/HackYourFuture/Node.js/milestones{/number}","notifications_url":"https://api.github.com/repos/HackYourFuture/Node.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HackYourFuture/Node.js/labels{/name}","releases_url":"https://api.github.com/repos/HackYourFuture/Node.js/releases{/id}","deployments_url":"https://api.github.com/repos/HackYourFuture/Node.js/deployments","created_at":"2016-09-22T09:36:44Z","updated_at":"2018-06-22T10:15:58Z","pushed_at":"2018-09-22T17:28:48Z","git_url":"git://github.com/HackYourFuture/Node.js.git","ssh_url":"git@github.com:HackYourFuture/Node.js.git","clone_url":"https://github.com/HackYourFuture/Node.js.git","svn_url":"https://github.com/HackYourFuture/Node.js","homepage":"","size":695,"stargazers_count":26,"watchers_count":26,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":135,"mirror_url":null,"archived":false,"open_issues_count":38,"license":null,"forks":135,"open_issues":38,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246"},"html":{"href":"https://github.com/HackYourFuture/Node.js/pull/246"},"issue":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/issues/246"},"comments":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/issues/246/comments"},"review_comments":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246/comments"},"review_comment":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/pulls/246/commits"},"statuses":{"href":"https://api.github.com/repos/HackYourFuture/Node.js/statuses/383ed938803748cb3bba1fff8f99161551ebfcfd"}},"author_association":"NONE"}}
{"actor":{"display_login":"J05J4"}}