Skip to content

Commit

Permalink
Merge pull request #904 from goodeggs/docs/add-readme-typescript-note
Browse files Browse the repository at this point in the history
docs(readme): add note about TypeScript
  • Loading branch information
serhalp authored Oct 8, 2021
2 parents 697e5a3 + 8b5edaa commit 445176a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ jsonFetch('http://www.test.com/products/1234', {
});
```

### TypeScript

This library comes with built-in TypeScript type declarations.

Due to complexities in dealing with isomorphic-fetch - which uses whatwg-fetch in browsers and node-fetch
in node.js, which are subtly different - these type declarations only work if you include the `DOM` built-in
TypeScript lib in your `tsconfig.json`. For example:
```json
{
"lib": ["DOM", "ES2020"]
}
```
This happens implicitly if you don't set a `lib`.

This may be fixed in the future.

### Retry Behavior

By default, jsonFetch doesn't retry requests. However, you may opt in to jsonFetch's very flexible retry behavior, provided by the excellent [`promise-retry`](https://github.com/IndigoUnited/node-promise-retry) library. Here's a quick example:
Expand Down

0 comments on commit 445176a

Please sign in to comment.