docs: Include HTML base for browser people :D

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
Florian Bouillon 2023-01-11 20:54:16 +01:00
parent 4507bbd651
commit 09d8b28a66
Signed by: Florian Bouillon
GPG Key ID: BEEAF3722D0EBF64

View File

@ -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');
// Card will be Furret from the Darkness Ablaze Set // go into an async context
const card = await tcgdex.fetch('cards', 'swsh3-136'); (async () => {
// Card will be Furret from the Darkness Ablaze Set
const card = await tcgdex.fetch('cards', 'swsh3-136');
// You can also get the same result using
const card = await tcgdex.fetch('sets', 'Darkness Ablaze', 136);
})();
// You can also get the same result using
const card = await tcgdex.fetch('sets', 'Darkness Ablaze', 136);
``` ```
**Other Examples** **Other Examples**