massimocandela / bulk-whois-parser

A parser for bulk whois data
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

TypeError: WhoisParser is not a constructor. #5

Closed rlarmore closed 1 month ago

rlarmore commented 2 months ago

I’m getting this error when trying just a very basic example from your readme. When I console.log(WhoisParser) says it’s a {default: [Function: WhoisParser] }. Thanks for the help.

TypeError: WhoisParser is not a constructor at file:///Users/rlarmore/localwhois/index.js:25:21 at ModuleJob.run (node:internal/modules/esm/module_job:234:25) at async ModuleLoader.import (node:internal/modules/esm/loader:473:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

const filterFunction = (object) => {
    // A function that returns true or false, used to filter the results
    // Make this function as selective as possible, since the amount of whois data
    // can be overwhelming.
}

// The fields you want to see in the object. Use null to get all the fields
const fields = ["inetnum", "inet6num", "remarks"]; 

new WhoisParser({ repos: ["ripe", "lacnic", "apnic", "afrinic", "arin"] })
    .getObjects(["inetnum", "inet6num"], filterFunction, fields)
    .then(objects => {
        // Do something with the objects (array)
    });
rlarmore commented 1 month ago

Nvm figured it out.

const WhoisParser = require("bulk-whois-parser").default

massimocandela commented 1 month ago

Readme, line 15

import WhoisParser from "bulk-whois-parser";