From a5430135af9d543076a2acbb6a73489761289c41 Mon Sep 17 00:00:00 2001 From: Lofty-Brambles <100270817+Lofty-Brambles@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:27:41 +0530 Subject: [PATCH] fix: more grammar issues Co-authored-by: Mayada <115709272+Maddily@users.noreply.github.com> --- nodeJS/apis/RESTful_APIs.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nodeJS/apis/RESTful_APIs.md b/nodeJS/apis/RESTful_APIs.md index 9ef7c024e0..0a3bb988a4 100644 --- a/nodeJS/apis/RESTful_APIs.md +++ b/nodeJS/apis/RESTful_APIs.md @@ -33,7 +33,7 @@ Instead of having a naming convention like `/getPosts` or `/setPosts`, a request | PUT | Update | `PUT /posts/:postid` - Updates a single post | | DELETE | Delete | `DELETE /posts/:postid` - Deletes a single post | -There are usually 2 URLs for a resource - one for the entire collection and one for a single object in the collection. One can `GET /posts` for all of the posts or `GET /posts/:postid` for one of them. Nesting URLs further is entirely possible, `GET /post/:postid/comments` can get all the comments for a post, or `GET /post/:postid/comments/:commentid` can get a specific comment on a specific post. +There are usually 2 URLs for a resource - one for the entire collection and one for a single object in the collection. One can `GET /posts` for all of the posts or `GET /posts/:postid` for one of them. Nesting URLs further is entirely possible: `GET /posts/:postid/comments` can get all the comments for a post, while `GET /posts/:postid/comments/:commentid` can get a specific comment on a specific post. ### HTTP response status codes @@ -41,7 +41,7 @@ Every response from a server has a response code that provides quick and basic c #### Status codes 100 - 199: Informational responses -Introduced by the HTTP/1.1 standard, these simply represent that a request was received and understood, mostly used on a provisional basis while the request processing continues. It simply alerts the client to wait for a final response. +Introduced by the HTTP/1.1 standard, these indicate that a request was received and understood. They're mostly used on a provisional basis while the request processing continues, alerting the client to wait for a final response. #### Status codes 200 - 299: Successful responses @@ -52,7 +52,7 @@ These tell the client that a request was successfully received and processed. #### Status codes 300 - 399: Redirection messages -Whenever additional action is needed to complete the request, it is indicated to the client with this class of status codes. A major use case for these is URL redirection. +Whenever an additional action is needed to complete the request, it is indicated to the client with this class of status codes. A major use case for these is URL redirection. - `301 Moved Permanently`: Denotes the permanent relocation of any resource to a different URL, while adding the new URL to the response. @@ -67,7 +67,7 @@ These are used to report faults made by the client, like requesting a non-existe #### Status codes 500 - 599: Server error responses -Indicates when the server fails to process a request. +They indicate when the server fails to process a request. - `500 Internal Server Error`: A generic catch-all status code used to indicate an internal error faced by the server while processing the request. - `501 Not Implemented`: The server lacks the capabilities to fulfill the request or is unable to recognize the request method. @@ -91,9 +91,9 @@ http://sub.domain.com:1234/path/to/resource?query=something¶m=something#anch ### RESTful APIs -Simply put, an API is an interface. When an application needs to interact with another, it sends a request to the respective API. As you've learned in previous lessons, in the context of the web, any server that is created to serve data for external use is called an API. While you can structure your API in multiple ways, a popular and conventional method to do so is to follow REST (**Re**presentational **S**tate **T**ransfer). [The exact definition of REST](https://en.wikipedia.org/wiki/REST#Principle) might be a little complicated, but for us, it states that there is a set of standards to be followed to make our API, RESTful (adhere to the constraints set by REST). +Simply put, an API is an interface. When an application needs to interact with another, it sends a request to the respective API. As you've learned in previous lessons, in the context of the web, any server that is created to serve data for external use is called an API. While you can structure your API in multiple ways, a popular and conventional method to do so is to follow REST (**Re**presentational **S**tate **T**ransfer). [The exact definition of REST](https://en.wikipedia.org/wiki/REST#Principle) might be a little complicated, but for us, it states that there is a set of standards to be followed to make our API RESTful (adhere to the constraints set by REST). -Since we have already talked about separating the client and the server, it fulfills the first constraint of REST - the two are well-defined as the frontend and the backend. Further constraints like statelessness and caching are covered by and ensured later with ExpressJS. Our key concern at this point is the organization of endpoint URLs with respect to our resources. +Earlier, we mentioned separating the client and the server, which fulfills the first constraint of REST: the frontend and backend are well-defined. Further constraints like statelessness and caching are covered by and ensured later with ExpressJS. Our key concern at this point is the organization of endpoint URLs with respect to our resources. As mentioned, usually your backend application will need to send data to your frontend. The most popular way to do so by far is with JSON, primarily due to the ease of parsing it with JavaScript. So all we need to do is to replace our HTML and serve JSON instead. All that you have to do, thus, is to pass your information to [`res.json()`](https://expressjs.com/en/4x/api.html#res.json) instead of [`res.send()`](https://expressjs.com/en/4x/api.html#res.send) or [`res.render()`](https://expressjs.com/en/4x/api.html#res.render). @@ -102,10 +102,10 @@ As mentioned, usually your backend application will need to send data to your fr