npm-registry-fetch
npm-registry-fetch copied to clipboard
[QUESTION] How should body option be formatted?
Hey @isaacs. Trying to use package. But I'm not quite sure if I'm using it correctly 😀 . when trying to pass the contents of package-lock.json to opts.body like this...
const json = await npmFetch.json('/-/npm/v1/security/audits', {
method: 'POST',
body: packageLockJsonContents, // this is just the contents of a package-lock.json parsed as an object
});
console.log(JSON.stringify(json, '', 3));
But I get the following error:
Failed to fetch audit report for repo npm. status: 400 cause: {"statusCode":400,"error":"Bad Request","message":"Invalid request payload input"}
How should the opts.body be formatted? Thanks!
What is
typeof packageLockJsonContents
?
object. But I was assuming the package would automatically JSON.stringify with proper content-type.
sorry didn't mean to close this
How come it is not still answered? How to use it? What should be the type of body option?