Skip to main content
Go to Latest
File

client

Features

  • built-in error handling
  • convenient parsing

Usage

import { Client } from 'https://deno.land/x/darkflare@v7.0.0/client/mod.ts'

const client = new Client({
  base: 'https://example.com',
  headers: {
    authorization: 'bearer token'
  }
})

// note the absence of 'try catch'
const result = await client.get('/entries', { type: 'json' })

const result = await client.post('/entries/new', {
  data: {
    name: '',
    description: ''
  },
  headers: {
    'x-header': ''
  },
  type: 'json'
})

Result

  • data - The parsed response body.
  • error (unknown)
  • code (number)
  • ok (boolean)
  • headers (object)