Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong example at documentation page #861

Closed
ranierimazili opened this issue Jul 14, 2016 · 2 comments
Closed

Wrong example at documentation page #861

ranierimazili opened this issue Jul 14, 2016 · 2 comments

Comments

@ranierimazili
Copy link

@ranierimazili ranierimazili commented Jul 14, 2016

Hi,

at documentation site https://github.com/feross/webtorrent/blob/master/docs/get-started.md we have a section called Download and save a torrent (in Node.js) where there's an example code.
This example works well but you're showing messages at console using console.error:

fs.writeFile(file.name, buffer, function (err) {
console.error('Error saving ' + file.name)
})

But it's downloading successfully.

Probably the best example should be
fs.writeFile(file.name, buffer, function (err) {
if (err) {
console.error('Error saving ' + file.name)
} else {
console.log('File saved ' + file.name);
}
})

As I could see at writeFile documentation (https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) the 3rd parameters is for error, it's for a callback function.

This creates confusion with new developers using the library, because it's download successfully and at the console it show error messages.

@ranierimazili ranierimazili changed the title Wrong example at main page Wrong example at documentation page Jul 14, 2016
@feross feross closed this in e07939d Jul 29, 2016
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jul 29, 2016

thanks, fixed!

@lock

This comment has been minimized.

Copy link

@lock lock bot commented May 4, 2018

This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue.

@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.