From e7424de4ef9920bcec35c6b3bad15d37f5a4b947 Mon Sep 17 00:00:00 2001 From: Niraj Nandish Date: Tue, 12 Feb 2019 10:05:09 +0400 Subject: [PATCH] fix(challenge): typo error (#30359) --- .../basic-node-and-express/serve-json-on-a-specific-route.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md index 27f684f1ac..2780a4134e 100644 --- a/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md +++ b/curriculum/challenges/english/05-apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route.en.md @@ -7,7 +7,7 @@ challengeType: 2 ## Description
While an HTML server serves (you guessed it!) HTML, an API serves data. A REST (REpresentational State Transfer) API allows data exchange in a simple way, without the need for clients to know any detail about the server. The client only needs to know where the resource is (the URL), and the action it wants to perform on it (the verb). The GET verb is used when you are fetching some information, without modifying anything. These days, the preferred data format for moving information around the web is JSON. Simply put, JSON is a convenient way to represent a JavaScript object as a string, so it can be easily transmitted. -Let's create a simple API by creating a route that responds with JSON at the path /json. You can do it as usual, with the app.get() method. Inside the route handler use the method res.json(), passing in an object as an argument. This method closes the request-response loop, returning the data. Behind the scenes it converts a valid JavaScript object into a string, then sets the appropriate headers to tell your browser that you are serving JSON, and sends the data back. A valid object has the usual structure {key: data}. Data can ba a number, a string, a nested object or an array. Data can also be a variable or the result of a function call; in which case it will be evaluated before being converted into a string. +Let's create a simple API by creating a route that responds with JSON at the path /json. You can do it as usual, with the app.get() method. Inside the route handler use the method res.json(), passing in an object as an argument. This method closes the request-response loop, returning the data. Behind the scenes it converts a valid JavaScript object into a string, then sets the appropriate headers to tell your browser that you are serving JSON, and sends the data back. A valid object has the usual structure {key: data}. Data can be a number, a string, a nested object or an array. Data can also be a variable or the result of a function call, in which case it will be evaluated before being converted into a string. Serve the object {"message": "Hello json"} as a response in JSON format, to the GET requests to the route /json. Then point your browser to your-app-url/json, you should see the message on the screen.