Skip to content

Commit b539445

Browse files
authored
Update part3a.md
JSON.stringify(notes) doesn't convert array `notes` to JSON. It converts it to string.
1 parent 6b70596 commit b539445

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/3/en/part3a.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ console.log(`Server running on port ${PORT}`)
216216

217217
Let's restart the server (you can shut the server down by pressing _Ctrl+C_ in the console) and let's refresh the browser.
218218

219-
The <i>application/json</i> value in the <i>Content-Type</i> header informs the receiver that the data is in the JSON format. The _notes_ array gets transformed into JSON with the <em>JSON.stringify(notes)</em> method.
219+
The <i>application/json</i> value in the <i>Content-Type</i> header informs the receiver that the data is in the JSON format. The _notes_ array gets transformed into JSON string format with the <em>JSON.stringify(notes)</em> method. This is necessary because the response.end() method expects a string or a buffer to send as the response body.
220220

221221
When we open the browser, the displayed format is exactly the same as in [part 2](/en/part2/getting_data_from_server/) where we used [json-server](https://github.com/typicode/json-server) to serve the list of notes:
222222

@@ -340,7 +340,7 @@ The request is responded to with the [json](http://expressjs.com/en/4x/api.html#
340340

341341
Next, let's take a quick look at the data sent in JSON format.
342342

343-
In the earlier version where we were only using Node, we had to transform the data into the JSON format with the _JSON.stringify_ method:
343+
In the earlier version where we were only using Node, we had to transform the data into the JSON string format with the _JSON.stringify_ method:
344344

345345
```js
346346
response.end(JSON.stringify(notes))

0 commit comments

Comments
 (0)