Skip to content

Commit

Permalink
Fix typo: rename outoutPath to outputPath in "reading-files-with-node…
Browse files Browse the repository at this point in the history
…js.md"

Signed-off-by: Nihat <[email protected]>
  • Loading branch information
nihat-js authored Mar 5, 2025
1 parent f33bf00 commit 9788d74
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ import { pipeline } from 'node:stream/promises';
const fileUrl = 'https://www.gutenberg.org/files/2701/2701-0.txt';
const outputFilePath = path.join(process.cwd(), 'moby.md');

async function downloadFile(url, outoutPath) {
async function downloadFile(url, outputPath) {
const response = await fetch(url);

if (!response.ok || !response.body) {
throw new Error(`Failed to fetch ${url}. Status: ${response.status}`);
}

const fileStream = fs.createWriteStream(outoutPath);
console.log(`Downloading file from ${url} to ${outoutPath}`);
const fileStream = fs.createWriteStream(outputPath);
console.log(`Downloading file from ${url} to ${outputPath}`);

await pipeline(response.body, fileStream);
console.log('File downloaded successfully');
Expand Down

0 comments on commit 9788d74

Please sign in to comment.