Skip to main content

Setting API Token

The API token used by the PRCI can be set in multiple ways depending on your use-case.

For all of these methods, let's assume we have a PRCI element exposed as follows:

<body>
<bldn-priv-request id='prci'></bldn-priv-request>
<script src="https://cdn.jsdelivr.net/npm/@blindnet/prci@0.12.3/dist/index.all.min.js" type="module"></script>
</body>

Via Attribute

In HTML Template

When using Lit templates or a templating language such as JSX.

Lit

<bldn-priv-request id='prci' api-token=${token}></bldn-priv-request>

React

<bldn-priv-request id='prci' api-token={token}></bldn-priv-request>

In Javascript

See the authentication step of the intro tutorial for a full example of this method.

function submit() {
fetch(`http://some-domain/token-endpoint`)
.then(token => {
document.getElementById('prci').setAttribute('api-token', `${token}`)
})
}