NW5-Manchester-Khadar-Prep-work-Node-W3#17
Open
khmdagal wants to merge 3 commits intoCodeYourFuture:masterfrom
Open
NW5-Manchester-Khadar-Prep-work-Node-W3#17khmdagal wants to merge 3 commits intoCodeYourFuture:masterfrom
khmdagal wants to merge 3 commits intoCodeYourFuture:masterfrom
Conversation
Ara225
reviewed
Jan 21, 2023
|
|
||
| // reading All albums | ||
| app.get("/albums", (req, res) => { | ||
| fs.readFile("./albums.json", "utf-8").then((movie) => { |
There was a problem hiding this comment.
You don't write to this file, so it doesn't neccessarily make sense to read it everytime you make a request. require() will do the job
| const id = +req.params.id; | ||
| const index = fs.readFile("./albums.json", "utf-8").then((movie) => { | ||
| const searchedAlbum = JSON.parse(movie).findIndex( | ||
| (album) => +album.id === +req.params.id |
There was a problem hiding this comment.
I prefer to be a little more explict with my number conversions, this syntax is a little hard to read quickly, but this is a matter of personal preference
| const newAlbum = { | ||
| album: requestBody.album, | ||
| artist: requestBody.artist, | ||
| id: theOldAlbum.id, // here I want don't want to change the old id |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
master