Skip to content

London10-AfshaHossain-Node-Week1-Node-Starter-Kit#26

Open
Afsha10 wants to merge 5 commits intoCodeYourFuture:masterfrom
Afsha10:master
Open

London10-AfshaHossain-Node-Week1-Node-Starter-Kit#26
Afsha10 wants to merge 5 commits intoCodeYourFuture:masterfrom
Afsha10:master

Conversation

@Afsha10
Copy link

@Afsha10 Afsha10 commented Jul 17, 2023

No description provided.

@Afsha10 Afsha10 force-pushed the master branch 5 times, most recently from 64236ef to 4949894 Compare July 22, 2023 08:04
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"
},
@Afsha10 Afsha10 force-pushed the master branch 3 times, most recently from d960c71 to bbd6d6a Compare July 25, 2023 00:27
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant