0.7.9 • Published 4 years ago

kayden v0.7.9

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Kayden - (Beta)

Overview

A light weight promise based request client.

Both XMLHttpRequests for browsers and HTTP for node.js

Installation

$ npm install kayden

Usage

Get

import kayden from 'kayden'

const url = 'https://jsonplaceholder.typicode.com/posts'

const data = async () => {
  try {
    const response = await kayden.get(url)
    return response
  } catch (e) {
    console.warn(e)
  }
}

Post

import kayden from 'kayden'
const config = {
  url: 'https://jsonplaceholder.typicode.com/posts',
  body: {
    id: 101,
    title: 'foo',
    body: 'bar',
    userId: 1
  },
}

const data = async () => {
  try {
    const response = await kayden.post(config.url, config.body)
    return response
  } catch (e) {
    console.warn(e)
  }
}

.then().catch() syntax

import kayden from 'kayden'

  kayden.get('https://jsonplaceholder.typicode.com/posts')
  .then(res => {
    console.log(res)
  })
  .catch(e => {
    console.warn(e)
  })
}

Methods

Methods used on the instances:

kayden#get(url , options)

kayden#post(url , body)

kayden#put(url , body)

kayden#patch(url , body)

kayden#delete(url , options)

0.7.9

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.3

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago