-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
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#customizing-the-fetch-api-with-undici
Describe the issue in detail:
It is important to always either consume or cancel the response body anyway, but it isn't correctly handled in the example code, which may mislead new learners:
const { statusCode, body } = await ollamaPool.request({ path: '/api/generate', method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ prompt, model: 'mistral' }), }); // You can read about HTTP status codes here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status // 200 means the request was successful. if (statusCode !== 200) { throw new Error(`Ollama request failed with status ${statusCode}`); }
Metadata
Metadata
Assignees
Labels
contentIssues/pr concerning contentIssues/pr concerning contentlearnIssues/pr concerning the learn sectionIssues/pr concerning the learn section
Type
Projects
Status
✅ Done