@digital-passports/javascript-sdk
Version:
JavaScript SDK for interacting with the Digital Passport Hub REST API.
24 lines (19 loc) • 1.32 kB
Markdown
# Raw JavaScript Local Example
This example demonstrates how to use the Digital Passport Hub JavaScript SDK with plain JavaScript (no frameworks), loading the SDK from your local project build.
## Usage
1. Make sure you have built the SDK:
```
npm run build
```
2. **Serve the project from the root directory** (not from inside this example folder):
```
npx serve .
```
3. Open [http://localhost:5000/examples/raw-js-local/index.html](http://localhost:5000/examples/raw-js-local/index.html) (or the port shown in your terminal).
4. Enter your API key, then use the buttons to list or create passports.
The SDK is loaded from `../../dist/javascript-sdk.umd.js` relative to this example.
## Troubleshooting
- **If you see `Uncaught ReferenceError: require is not defined`:**
- This means the UMD bundle is still including a `require` statement. The SDK source and build process must ensure that all `require` calls are only ever used in Node.js and never included in the browser bundle. If you see this error, please rebuild the SDK after ensuring all `require` calls are inside dynamic imports or runtime-only Node.js code.
- **If you see a 404 for the UMD bundle:**
- Make sure you are running the static server from the project root, not from inside the example folder.