doowb / npm-api

Node.js library for getting info from NPM’s API
https://github.com/doowb/npm-api
MIT License
105 stars 18 forks source link

Example with View doesn't work #13

Open metronom72 opened 4 years ago

metronom72 commented 4 years ago

The next code doesn't work. It mostly from the example

import NpmApi from 'npm-api';

export const search = async (query) => {
  try {
    const npm = new NpmApi();
    debugger;
    let view = npm.view('listAll');
    let pkg = await view.query({
      // group_level: 4,
      startkey: JSON.stringify(['react']),
      endkey: JSON.stringify(['react', {}])
    });
    debugger
    if (pkg.length > 0) {
      let val = pkg[0].value;
      let latest = val.versions[val['dist-tags'].latest];
    }
    debugger
  } catch (err) {
    console.log(err);
    throw err;
  }
}

I know that package react ixists, but code upper there shows that such package doesn't exist.

doowb commented 4 years ago

Sorry, I missed this before. NPM has made some changes and I think I'll need to make updates to the .view and .list methods. I might not be able to keep those in here.