Skip to content

Commit

Permalink
Merge pull request #18 from node-girls/step9
Browse files Browse the repository at this point in the history
moves fs details from step 9 to step 8. adds res.sendFile info'
  • Loading branch information
claireinez authored Jul 2, 2016
2 parents 19cffb2 + b9e75cd commit 65f5f54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions step08.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ Here's a breakdown of what you want to achieve:
* Add your new blog post data to the old ones.
* Write your new combined data back to the `posts.json` file.

### Things to remember
* `fs.writeFile()` normally overwrites the target file you've given it. Chances are you don't want to lose all your old blog posts every time you get a new one, so think about how you can combine `fs.readFile()` and `fs.writeFile()` to prevent overwriting.

* You will need to convert between JSON and a JavaScript object several times. `JSON.parse()` and `JSON.stringify()` are what you need.

Oh by the way, if you want to get the current timestamp, use the JavaScript `Date.now()` method.

Good luck!
Expand Down
4 changes: 1 addition & 3 deletions step09.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ If you look inside `public/script.js`, there's a whole bunch of JavaScript code

Your `script.js` file will want to receive the JSON containing your blog posts. Your job is to make that happen!

### Things to remember
* `fs.writeFile()` normally overwrites the target file you've given it. Chances are you don't want to lose all your old blog posts every time you get a new one, so think about how you can combine `fs.readFile()` and `fs.writeFile()` to prevent overwriting.
Express has a handy method called `res.sendFile()` that makes it easy to send files back to the client. Feel free to use this with your JSON.

* You will need to convert between JSON and a JavaScript object several times. `JSON.parse()` and `JSON.stringify()` are what you need.

If all goes well, you should have a fully functional CMS!

Expand Down

0 comments on commit 65f5f54

Please sign in to comment.