observing / fullcontact

FullContact API bindings for Node.js
MIT License
42 stars 18 forks source link

Batch requests #1

Closed jcurtis closed 9 years ago

jcurtis commented 11 years ago

I can see references in the src that mention doing batch requests but I can't find any examples that actually use it. Is this feature implemented and if so are there any example tests?

3rd-Eden commented 11 years ago

I haven't written tests against it, but the batch requests are supported. There are 2 API methods that you need to know about. That's the fullcontact#multi and the fullcontact#exec. The multi method returns a new FullContact API instance that's internally set to queuing. So all api endpoints you would hit are queued until you call the exec method. This works the same as the multi / exec functionality of the redis module in node.js.

Example:

var multi = fullcontact.multi();

multi.person.facebook('arnout.kazemier', fn);
multi.person.facebook('john.appleseed', fn);

multi.exec(function (err) {
  console.log(err);
})

Hope this helps.

jcurtis commented 11 years ago

Awesome this helps immensely. Thanks for the help and the lib. Maybe I'll submit a PR with some tests if I get to it.