0

I am trying to use pipl with Node.js. I have written the following code:

router.post('/httpOnly/enrich/pipl', (req, res) => {
    var pipl = require('pipl')('BUSINESS-PREMIUM-DEMO-xyozhmgkc57085z7...');
    pipl.search.query('json', {"email": "[email protected]"}, function(err, data) {
        console.log(data);
        res.json(data)
    });
})

However, it gave an error:

index.js POST /httpOnly/enrich/pipl
http://api.pipl.com/search/v4/
/.../node_modules/pipl/lib/inherits.js:32
                    return callback(err, JSON.parse(body) || body);
                           ^

TypeError: callback is not a function
    at Request._callback (/.../node_modules/pipl/lib/inherits.js:32:28)
    at Request.self.callback (/.../node_modules/request/request.js:123:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (/.../node_modules/request/request.js:893:14)
    at emitOne (events.js:120:20)
    at Request.emit (events.js:210:7)
    at IncomingMessage.<anonymous> (/.../node_modules/request/request.js:844:12)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Does anyone know what's wrong?

1 Answer 1

1

From the documentation it looks like the syntax is:

pipl.search.query({"email": "[email protected]"}, function(err, data) {
    console.log(data);
    res.json(data)
});

Without the 'json' string at the beginning. I think the signature was changed without the documentation on npm being updated.

Check this commit too.

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you... I got another error { '@http_status_code': 403, error: 'This API key is for API version 5. You tried using version 4' }.
@SoftTimur I see you made an issue on the GitHub repo. You can try removing v4/ on this line and see if that works. According to the API documentation it looks like they removed the version from the URL. The pipl library you are using is generally out of date, that's the problem.
Removing that line in my local node_modules/pipl/lib/main.js did solve the problem. Now, how could I keep this version even after sudo npm install? Do I have to make a bash to systematically replace that file?
@SoftTimur You can fork the repo on GitHub, fix it in your forked repo and commit, and then link to the GitHub repo in package.json.
You don't have to publish to npm. You can use github links in package.json. E.g. "pipl": "https://github.com/softtimur/pipl/tarball/master". See here. The license is MIT so you can fork it without problems. You only have to retain the copyright notices in the comments. If you haven't forked on GitHub before you can look here.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.