London10-AfshaHossain-Node-Week1-Node-Starter-Kit#26
Open
Afsha10 wants to merge 5 commits intoCodeYourFuture:masterfrom
Open
London10-AfshaHossain-Node-Week1-Node-Starter-Kit#26Afsha10 wants to merge 5 commits intoCodeYourFuture:masterfrom
Afsha10 wants to merge 5 commits intoCodeYourFuture:masterfrom
Conversation
64236ef to
4949894
Compare
Completed Ex 3.1 : Get All Albums
a) In server.js Add the endpoint for GET /albums.
b) Test the endpoint with Postman. GET /albums should return a JSON reply with the array we specified.
c) Add another item to the array and test that the GET /albums returns three items.
Completed Ex 3.3: Install Nodemon, a handy npm package
npm install --save-dev nodemon
Made sure the package is added to your package.json, added this line to the script:
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
},
d960c71 to
bbd6d6a
Compare
We achieved that by using req.params.albumId and storing the value in a variable called albumIdToFind. Then using the .find method on the albumsData to find the album that has the matching id or albumIdToFind and then display that single album. Tested by sending: localhost:35981/albums/11 to get the album that has 11 as its id.
Added the following album by using request.body and then using .push method to append the new album to the albums data and finally sending it as a response:
{
"albumId": "13",
"artistName": "Beyoncé",
"collectionName": "B'Day (Deluxe Edition)",
"artworkUrl100": "http://is5.mzstatic.com/image/thumb/Music/v4/6c/fc/6a/6cfc6a13-0633-f96b-9d72-cf56774beb4b/source/100x100bb.jpg",
"releaseDate": "2007-05-29T07:00:00Z",
"primaryGenreName": "Pop",
"url": "https://www.youtube.com/embed/RQ9BWndKEgs?rel=0&controls=0&showinfo=0"
}
Tested by sending: localhost:35981/albums to check the new album is added to all albums list.
This means that DELETE /albums/2 deletes an album with the id 2 and return 200 with JSON { success: true } to the user.
To delete an album with ID 13 we send localhost:35981/albums in POSTMAN.
Tested by sending: localhost:35981/albums to check a particular album is deleted
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.
No description provided.