This repository was archived by the owner on Aug 17, 2024. It is now read-only.
Open
Conversation
Author
|
New pages |
nennes
reviewed
Jul 21, 2018
| app.set("view engine", "handlebars"); | ||
|
|
||
| app.post("/subscribe", function(req, res) { | ||
| var email = req.fields.mail; |
There was a problem hiding this comment.
it's better to use const or let instead of var
nennes
reviewed
Jul 21, 2018
|
|
||
| // Write the file with the whole new content | ||
| fs.writeFile(__dirname + "/data/posts.json", newContent, function(error) { | ||
| res.end("success!"); |
There was a problem hiding this comment.
in real life you'd send a JSON to the frontend, maybe something like:
{
status: 'SUCCESS'
}
nennes
reviewed
Jul 21, 2018
| var mailingList = JSON.parse(content); | ||
|
|
||
| //Convert the object in an array with the emails | ||
| var emails = Object.keys(mailingList).map(function(key) { |
There was a problem hiding this comment.
have you tried arrow functions? You could give it a try here!
nennes
reviewed
Jul 21, 2018
|
|
||
| // array emails to handlebars | ||
| res.render("subscribers", { | ||
| subscribersMail: emails |
nennes
reviewed
Jul 21, 2018
| <h1>Subscribers - Mailing List</h1> | ||
|
|
||
| <ul> | ||
| {{#each subscribersMail}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.