README
@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)
}
})()