Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Week 2 homework #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Week 2 homework #11

wants to merge 2 commits into from

Conversation

AlfiYusrina
Copy link

I haven't been able to finish the GET/delete, hopefully, I fix this by tomorrow.

@dfdeagle47
Copy link
Owner

Good job so far.

Here are some additional pointers

  • GET /posts: right now you're returning HTML (with the div, h1, li, etc.). When you're doing a REST API, you will instead return raw JavaScript objects using JSON. The rendering with the HTML will be done client-side: it gets the raw data, and processes it to transform to HTML according the client-side application logic. You will explore the client-side part when doing the React module. In the meantime, you can just send the JavaScript objects from the server.
  • GET /posts/:postId : looks good. Same remark as above: just send the JavaScript object directly.
  • GET /posts/:postId/delete : you will have to remove the post from the array. One way to do this is to create a new array without the deleted post and change the value of the posts variable (you might have to change const posts = ... to let posts = ... in the code to do this). You should look at the array methods which might let you do this (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).

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.

2 participants