Skip to content

Commit abfc3e3

Browse files
committed
chore: renamed data variable into buffer to avoid confusion with the data event
1 parent 7ac9ba0 commit abfc3e3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

06-coding-with-streams/28-stream-consumers/accumulate-http-consumers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import consumers from 'node:stream/consumers'
44
const req = request(
55
'https://jsonplaceholder.typicode.com/todos/1',
66
async res => {
7-
const data = await consumers.json(res)
8-
console.log(data)
7+
const buffer = await consumers.json(res)
8+
console.log(buffer)
99
}
1010
)
1111
req.end()
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const res = await fetch('https://jsonplaceholder.typicode.com/todos/1')
2-
const data = await res.json()
3-
console.log(data)
2+
const buffer = await res.json()
3+
console.log(buffer)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { request } from 'node:https'
22

33
const req = request('https://jsonplaceholder.typicode.com/todos/1', res => {
4-
let data = ''
4+
let buffer = ''
55
res.on('data', chunk => {
6-
data += chunk
6+
buffer += chunk
77
})
88
res.on('end', () => {
9-
console.log(JSON.parse(data))
9+
console.log(JSON.parse(buffer))
1010
})
1111
})
1212
req.end()

0 commit comments

Comments
 (0)