Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How should body option be formatted? #34

Open
markcellus opened this issue Sep 27, 2020 · 4 comments
Open

[QUESTION] How should body option be formatted? #34

markcellus opened this issue Sep 27, 2020 · 4 comments

Comments

@markcellus
Copy link

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!

@markcellus markcellus changed the title How should body option be formatted? [QUESTION] How should body option be formatted? Sep 27, 2020
@sosoba
Copy link

sosoba commented Jan 5, 2021

What is

typeof packageLockJsonContents

?

@markcellus
Copy link
Author

markcellus commented Jan 7, 2021

object. But I was assuming the package would automatically JSON.stringify with proper content-type.

@markcellus
Copy link
Author

sorry didn't mean to close this

@markcellus markcellus reopened this Jan 7, 2021
@illicit-oblivion
Copy link

How come it is not still answered? How to use it? What should be the type of body option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants