Lint example code

This commit is contained in:
Antoni Kepinski 2020-03-13 18:01:45 +01:00 committed by GitHub
parent 3c3558e259
commit e59db18432
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -36,10 +36,10 @@ Prior to v3.x, we included a `browser` field in the package.json file. Since nod
If you want charset encoding detection, please use the [fetch-charset-detection] package ([documentation][fetch-charset-detection-docs]).
```js
const fetch = require("node-fetch");
const convertBody = require("fetch-charset-detection");
const fetch = require('node-fetch');
const convertBody = require('fetch-charset-detection');
fetch("https://somewebsite.com").then(res => {
fetch('https://somewebsite.com').then(res => {
const text = convertBody(res.buffer(), res.headers);
});
```
@ -49,9 +49,9 @@ fetch("https://somewebsite.com").then(res => {
When attempting to parse invalid json via `res.json()`, a `SyntaxError` will now be thrown instead of a `FetchError` to align better with the spec.
```js
const fetch = require("node-fetch");
const fetch = require('node-fetch');
fetch("https://somewebsitereturninginvalidjson.com").then(res => res.json())
fetch('https://somewebsitereturninginvalidjson.com').then(res => res.json())
// Throws 'Uncaught SyntaxError: Unexpected end of JSON input' or similar.
```