Got: JSON parsing broken?

Created on 24 Jan 2019  路  10Comments  路  Source: sindresorhus/got

Describe the bug

  • Node.js version: v10.14.2 / v8.14.0
  • OS & version: macOs 10.14.2 / CodeSandbox

Not sure what I'm missing but somehow got won't parse (aka. JSON parse) a server's JSON output, tried two different servers that do have the Content-Type header set.

Also the got(url).json() found in the current README does not work, it fails with a method not found error.

Must be something stupid... 馃

Actual behavior

Do not parse JSON and return raw body as string

Expected behavior

Parses JSON and returns an object/array

Code to reproduce

https://codesandbox.io/s/xjyvn5r2y4

Checklist

  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and Got.

Most helpful comment

May be you don't know, but your Github main page is your only documentation site and it has exactly nothing common with a current stable version.
It would make a lot of sense to change your default version to the stable one or at least make this label big and red.

All 10 comments

From the top of the readme:

This readme reflects the next major version that is currently in development. You probably want the v9 readme.

May be you don't know, but your Github main page is your only documentation site and it has exactly nothing common with a current stable version.
It would make a lot of sense to change your default version to the stable one or at least make this label big and red.

It would make a lot of sense to change your default version to the stable one or at least make this label big and red.

It's already at the top of the readme and in bold.

Development on master (main branch) is how most projects on GitHub work. It's expected knowledge that you go to the specific tag you're using for documentation or the npm package.

You should keep developing on master branch but could change github 芦聽default聽禄 branch to be the stable one, aka the one that will be selected by default when arriving on the project page. Would be less confusing imo.

Also for me have no sense to have a default documentation page that does not respect the default version downloaded with NPM.

So you are saying the your master branch in not the latest version of your package? :confused:
Please consider to use a more strong pattern like GitHub Flow or Gitflow where master branch must reflect the latest deployed version.

Just a suggestion to use better the git tool, now you're not using it correctly and this create a lot of confusion.

Could you put the note at the very top? It doesn't exactly jump out of the page, for me.

image

We have an alpha version of v10 out if you wanna help us test: https://github.com/sindresorhus/got/releases/tag/v10.0.0-alpha.1

@sindresorhus we're seeing the .json is not a function on v10.6.0 on Alpine Linux running in Circle CI. Node 12.16.1. I might be able to spin up a public project on Circle to demonstrate a reproduction, but would probably have to add you as collab for triage. Before I report this is new and go through those steps - is this a known issue, or any thoughts?

@shellscape Can you reproduce it on RunKit or create an example repository?

@szmarczak no, I'd have to create a CI or equivalent container environment, as mentioned. We've only been able to reproduce in that environment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erfanium picture erfanium  路  3Comments

khizarsonu picture khizarsonu  路  3Comments

sindresorhus picture sindresorhus  路  3Comments

alvis picture alvis  路  3Comments

lukehorvat picture lukehorvat  路  3Comments