The sdk-tag
is a JavaScript SDK (Software Development Kit) designed to interact with
an API that generates and validates JWTs.
You can install the `sdk-tag
npm install @wral/sdk-tag
To use the sdk-tag
, you first need to import it into your JavaScript or TypeScript project:
import { createClient } from '@wral/sdk-tag';
Then, you can create a client instance with your configuration:
const config = {
baseUrl: 'YOUR_BASE_URL', // Base URL of your API
};
const client = createClient(config);
After creating the client instance, you can use its methods to interact with the API. Here are some examples:
// List tags related to weather
let tags = await client.listTags({ query: 'weather' });
let result = await client.attachTag(tags[0].id, { url: 'https://www.wral.com/weather/' });
Creates a new client instance with the provided configuration.
-
config
: An object containing API configuration parameters:-
baseUrl
: The base URL of the API.
-
Returns a client instance with methods for interacting with the API.
-
api: (path, options = {})
: fetch wrapper for the API. -
listTags({ query } = {})
: list tags -
putTag(tag)
: create a tag -
getTag(tagId)
: read a tag -
deleteTag(tagId)
: delete a tag -
attachTag(tagId, resource)
: attach a tag to a resource -
detachTag(tagId, { url })
: detach a tag from a resource -
query({ query } = {})
: query tagged resource