mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-04-22 10:42:10 +00:00
docs: Include HTML base for browser people :D
Signed-off-by: Avior <github@avior.me>
This commit is contained in:
parent
4507bbd651
commit
09d8b28a66
23
README.md
23
README.md
@ -63,19 +63,40 @@ _Note: a complete documentation is available at [TCGdex.dev](https://www.tcgdex.
|
|||||||
|
|
||||||
**Example: Fetch a Card**
|
**Example: Fetch a Card**
|
||||||
|
|
||||||
|
_in Browser_
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@tcgdex/sdk@2.4.9/dist/tcgdex.browser.js"></script>
|
||||||
|
<script>
|
||||||
|
// Instantiate the SDK
|
||||||
|
const tcgdex = new TCGdex('en');
|
||||||
|
|
||||||
|
// go into an async context
|
||||||
|
;(async () => {
|
||||||
|
// Card will be Furret from the Darkness Ablaze Set
|
||||||
|
const card = await tcgdex.fetch('cards', 'swsh3-136');
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
_in NodeJS (in an async context)_
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Import the SDK in Typescript
|
// Import the SDK in Typescript
|
||||||
import TCGdex from '@tcgdex/sdk';
|
import TCGdex from '@tcgdex/sdk';
|
||||||
|
|
||||||
// Instantiate the SDK
|
// Instantiate the SDK
|
||||||
// note: you can use one of the following lanugages
|
|
||||||
const tcgdex = new TCGdex('en');
|
const tcgdex = new TCGdex('en');
|
||||||
|
|
||||||
|
// go into an async context
|
||||||
|
(async () => {
|
||||||
// Card will be Furret from the Darkness Ablaze Set
|
// Card will be Furret from the Darkness Ablaze Set
|
||||||
const card = await tcgdex.fetch('cards', 'swsh3-136');
|
const card = await tcgdex.fetch('cards', 'swsh3-136');
|
||||||
|
|
||||||
// You can also get the same result using
|
// You can also get the same result using
|
||||||
const card = await tcgdex.fetch('sets', 'Darkness Ablaze', 136);
|
const card = await tcgdex.fetch('sets', 'Darkness Ablaze', 136);
|
||||||
|
})();
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Other Examples**
|
**Other Examples**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user