kevva / npm-user-packages

Get packages by a npm user
MIT License
42 stars 2 forks source link

Switch from 'got' dependency to native fetch? #1

Open JoshuaKGoldberg opened 1 year ago

JoshuaKGoldberg commented 1 year ago

Hi there - thanks for making this package! I've found it to be very handy. ❤️

Coming over from https://github.com/JoshuaKGoldberg/tidelift-me-up/issues/26 though: there's a dependency on a very old version of got: https://github.com/kevva/npm-user-packages/blob/aa001c2701ff59f15b6570578c5c27be8363171d/package.json#L30

got is a relatively heavy-weight library, with quite a few dependencies. But npm-user-packages just uses it for a single JSON fetch request. Would you be open to using fetch natively, now that it's in Node (https://nodejs.org/dist/latest-v18.x/docs/api/globals.html)? I'd be happy to send a PR!

- return got(url, {json: true}).then(res => {
+ return fetch(url, { headers: { 'Content-Type': 'json' }}).then(res => {
JoshuaKGoldberg commented 1 year ago

ping @kevva - is this still something you're interested in maintaining?

JoshuaKGoldberg commented 10 months ago

Well, I ended up making https://github.com/JoshuaKGoldberg/npm-username-to-packages instead.

import { npmUsernameToPackages } from "npm-username-to-packages";

await npmUsernameToPackages("joshuakgoldberg");