-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Open
Labels
contentIssues/pr concerning contentIssues/pr concerning contentlearnIssues/pr concerning the learn sectionIssues/pr concerning the learn section
Description
Affected URL
https://nodejs.org/en/learn/getting-started/fetch#streaming-responses-with-undici
Describe the issue in detail:
The current code example tries to destructure the statusCode property directly on the Stream function return value, but the statusCode is located on the StreamFactoryData
const { statusCode } = await stream(
url,
{
method: 'GET',
headers: {
'User-Agent': 'undici-stream-example',
Accept: 'application/json',
},
},
() => {
let buffer = '';
...It is also parsing the incomplete JSON during the stream which results in several SyntaxError: Unterminated string in JSON errors
try {
const json = JSON.parse(buffer);
console.log(
'Repository Names:',
json.map(repo => repo.name)
);
buffer = '';
} catch (error) {
console.error('Error parsing JSON:', error);
}Metadata
Metadata
Assignees
Labels
contentIssues/pr concerning contentIssues/pr concerning contentlearnIssues/pr concerning the learn sectionIssues/pr concerning the learn section
Type
Projects
Status
📋 Backlog