kayden

    0.7.9 • Public • Published

    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] [, options])

    kayden#put(url [, body] [, options])

    kayden#patch(url [, body] [, options])

    kayden#delete(url [, options])

    Install

    npm i kayden

    DownloadsWeekly Downloads

    5

    Version

    0.7.9

    License

    ISC

    Unpacked Size

    114 kB

    Total Files

    20

    Last publish

    Collaborators

    • kiranearle