wip credential generation example
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
# mixFetch Usage Example
|
||||
# Nym credential generation Usage Example
|
||||
|
||||
This is a simple project to show you how to use mixFetch.
|
||||
|
||||
Basic usage is as simple as replacing `fetch` with `mixFetch` in your code:
|
||||
This is a simple project to show you how to use nym credential generation.
|
||||
|
||||
```ts
|
||||
import { mixFetch } from '@nymproject/mix-fetch';
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<h1>Credential</h1>
|
||||
<input placeholder="mnemonic"></input>
|
||||
<input placeholder="amount"></input>
|
||||
<button onclick="getCredentials()">Get Credential</button>
|
||||
<button id="button">Get Credential</button>
|
||||
<div id="credential"></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -4,10 +4,17 @@ import { appendOutput } from './utils';
|
||||
async function main() {
|
||||
const mnemonic = document.getElementById('mnemonic') as HTMLInputElement;
|
||||
const coin = document.getElementById('coin') as HTMLInputElement;
|
||||
const button = document.getElementById('button') as HTMLButtonElement;
|
||||
const client = await createNymCredentialsClient({ isSandbox: true }); // options: {isSandbox?: boolean; networkDetails?: {}}
|
||||
|
||||
const credential = await client.comlink.acquireCredential(coin.value, mnemonic.value, {});
|
||||
appendOutput(JSON.stringify(credential, null, 2));
|
||||
const generateCredential = async () => {
|
||||
const credential = await client.comlink.acquireCredential(coin.value, mnemonic.value, {});
|
||||
appendOutput(JSON.stringify(credential, null, 2));
|
||||
};
|
||||
|
||||
if (button) {
|
||||
button.addEventListener('click', () => generateCredential());
|
||||
}
|
||||
}
|
||||
|
||||
// wait for the html to load
|
||||
@@ -15,3 +22,4 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
// let's do this!
|
||||
main();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user