Skip to content

Commit

Permalink
Improve example in documentation for using umd.js (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
himynameisdave authored and sindresorhus committed Nov 6, 2019
1 parent c5821a7 commit 3b87b93
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ Upload the [`index.js`](index.js) file in this repo somewhere, for example, to y

```html
<script type="module">
// Replace the version number with the latest version
import ky from 'https://cdn.jsdelivr.net/npm/ky@0.11.0/index.js';
import ky from 'https://cdn.jsdelivr.net/npm/ky@latest/index.js';
(async () => {
const parsed = await ky('https://jsonplaceholder.typicode.com/todos/1').json();
Expand All @@ -487,13 +486,12 @@ import ky from 'https://cdn.jsdelivr.net/npm/ky@0.11.0/index.js';
Alternatively, you can use the [`umd.js`](umd.js) file with a traditional `<script>` tag (without `type="module"`), in which case `ky` will be a global.

```html
<!-- Replace the version number with the latest version -->
<script src="https://cdn.jsdelivr.net/npm/ky@0.11.0/umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ky@latest/umd.js"></script>
<script>
(async () => {
const ky = ky.default;
const client = ky.default;
const parsed = await ky('https://jsonplaceholder.typicode.com/todos/1').json();
const parsed = await client('https://jsonplaceholder.typicode.com/todos/1').json();
console.log(parsed.title);
//=> 'delectus aut autem
Expand Down

0 comments on commit 3b87b93

Please sign in to comment.