mirror of
https://github.com/tcgdex/javascript-sdk.git
synced 2025-07-23 14:59:51 +00:00
Compare commits
6 Commits
v2.4.8
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
06e6f7639d | |||
09d8b28a66
|
|||
4507bbd651
|
|||
8a89aefe73 | |||
8df969c1db
|
|||
2177e9c088 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# Follow current releases https://nodejs.org/en/about/releases/
|
# Follow current releases https://nodejs.org/en/about/releases/
|
||||||
node-version: [12.x, 14.x, 16.x, 17.x, 18.x]
|
node-version: [14.x, 16.x, 18.x, 19.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
31
README.md
31
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');
|
||||||
|
|
||||||
// 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**
|
||||||
|
1545
package-lock.json
generated
1545
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tcgdex/sdk",
|
"name": "@tcgdex/sdk",
|
||||||
"version": "2.4.8",
|
"version": "2.4.9",
|
||||||
"main": "./dist/cjs/tcgdex.node.js",
|
"main": "./dist/cjs/tcgdex.node.js",
|
||||||
"module": "./dist/modules/tcgdex.node.js",
|
"module": "./dist/modules/tcgdex.node.js",
|
||||||
"types": "./dist/types/tcgdex.d.ts",
|
"types": "./dist/types/tcgdex.d.ts",
|
||||||
|
@ -3,4 +3,9 @@ import unfetch from 'unfetch'
|
|||||||
|
|
||||||
TCGdex.fetch = window.fetch ?? unfetch as any
|
TCGdex.fetch = window.fetch ?? unfetch as any
|
||||||
|
|
||||||
(global ?? window).TCGdex = TCGdex
|
if (typeof global !== 'undefined') {
|
||||||
|
global.TCGdex = TCGdex
|
||||||
|
}
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
(window as any).TCGdex = TCGdex
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user