kekto

1.0.1 • Public • Published

kekto npm Build Status dependencies Status

Dead simple fetch api in blocks

Installation

$ yarn add kekto

Usage

import {
  store as apiStore,
  refine,
  // if you want to check stored blocks
  getStorage,
  api
} from 'kekto'
 
const storage = getStorage()
 
// store new block
apiStore('unicorn', {
  // base url of api
  // if last character is '/', it will be sliced
  // so, it's not needed
  baseUrl: 'http://localhost:3000/api/v1',
  // [post, get, put, delete]
  // also sliced if first character is '/'
  post: 'add/unicorn',
  get: 'unicorn',
  // if you have everything on just one endpoint
  // use endpoint: '...'
  // => GET, POST, DELETE /unicorn
  endpoint: '/unicorn',
  // [json, text]
  accept: 'json',
  return: 'json'
})
 
// in case of updating already stored block
// => use kekto.refine() *it creates new block, so all opts are needed
refine('unicorn', {
  baseUrl: 'http://localhost:3000/api',
  endpoint: '/justcorn',
  accept: 'json',
  return: 'json'
})
 
console.log(storage)
 
// [GET, POST, PUT, DELETE] => fetch::Promise
api
  .GET('unicorn') // storage name
  .then(result => {
    console.log(result)
  })

Readme

Keywords

none

Package Sidebar

Install

npm i kekto

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • kocisov