-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION] How should body option be formatted? #34
Comments
What is typeof packageLockJsonContents ? |
|
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? |
The code here in npm cli gives some clues as to the expected structure, which it then passes to I can't find any source for this but I have a feeling that |
FWIW I had success with the following code snippet, which demonstrates the body internals that the 'audits' API expects and shows how to do a simple "are there any vulns/advisories?" lookup for 1 package, in this case // Actually you can omit the line below now that `fetch` is a built-in global, enabled by default since Node 18.
// const fetch = require('node-fetch');
const body = {
'name': 'package-which-depends-on-cookie-but-this-string-is-irrelevant',
'version': '0.0.0',
'requires': {
'cookie': '^0.4.2'
},
'dependencies': {
'cookie': {
'version': '0.4.2'
}
}
};
fetch('https://registry.npmjs.org/-/npm/v1/security/audits', {
method: 'POST',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
})
.then(res => {
return res.json();
})
.then(res => {
console.log(JSON.stringify(res, null, 2));
})
.catch(err => console.error(err)); |
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...But I get the following error:
How should the
opts.body
be formatted? Thanks!The text was updated successfully, but these errors were encountered: