@onlaw/node
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@onlaw/node

Onlaw's node client is a simple utility that can help authenticating with the API and getting a valid JWT.

Installation

Install the package

yarn add @onlaw/node

Use

Example

import { Onlaw } from '@onlaw/node'
import fetch from 'node-fetch'

const onlaw = new Onlaw({
  id: '',
  secret: '',
})

//
;(async () => {
  const token = await onlaw.getToken()

  try {
    const { data } = await fetch('https://api.onlaw.dk/graphql', {
      body: JSON.stringify({
        query: `mutation {
          link(html: "HTML") {
            id
          }
        }`,
      }),
      headers: {
        Authorization: `Bearer ${token.access_token}`,
      },
      method: 'post',
    })

    console.dir(data)
  } catch (error) {
    console.log(error)
  }
})()

Readme

Keywords

none

Package Sidebar

Install

npm i @onlaw/node

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

4.54 kB

Total Files

6

Last publish

Collaborators

  • yolen
  • denkristoffer