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

client.get(torrentId) not doing anything? #1002

Closed
davidgatti opened this issue Dec 18, 2016 · 3 comments
Closed

client.get(torrentId) not doing anything? #1002

davidgatti opened this issue Dec 18, 2016 · 3 comments

Comments

@davidgatti
Copy link

@davidgatti davidgatti commented Dec 18, 2016

The documentation states:

Returns the torrent with the given torrentId. Convenience method. Easier than searching through the client.torrents array. Returns null if no matching torrent found.

But when I write the following:

	//
	//	Get torrent info from the client
	//
	client.get(magnet, function (torrent) {

		//
		//	Content of the Magnet URL
		//
		let files = [];

		//
		//	Extract all the files form the Magnet URL
		//
		torrent.files.forEach(function(data) {

			files.push({
				name: data.name,
				length: data.length
			});

		});

		//
		//	->	Just say it is ok.
		//
		res.status(200)
		res.json(files);

	});

Nothing happens, no null no nothing. Where for example .add() works no problem. Am I doing something wrong?

  • WebTorrent version: 0.98.0
  • Node.js version: v6.4.0
  • Browser name/version (if using WebTorrent in the browser): Using NodeJS module.
@jo-san

This comment has been minimized.

Copy link

@jo-san jo-san commented Dec 25, 2016

Am also facing the same problem. In debugger i can get array of torrents from client.torrents but client.get(torrentId) returning null

Thanks,

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Dec 27, 2016

@davidgatti client.get(magnet) doesn't take a callback. It returns the given torrent.

This is what you want:

var torrent = client.get(magnet)
torrent.files.forEach(function () {})
@feross feross closed this Dec 27, 2016
@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
3 participants
You can’t perform that action at this time.