/faiqu

fetch for restful

Primary LanguageJavaScript

faiqu

fetch for restful api

Install

npm i faiqu --save

Simple example

import faiqu from 'faiqu'

faiqu('/api').params({id:1}).get().then(res=>{ console.log(res) })

APIs

Init Api

  1. faiquInit.baseUrl(url:string)

If the parameters you passed in the faiqu method are ' http://xxxx ', the method does not take effect

  1. faiquInit.preMethod(Array< Function >)
  2. faiquInit.defaultData(data:{})

key:string=>value:Function

  1. faiquInit.defaultHeader(data:{})

default:{ 'Content-type': 'application/x-www-form-urlencoded' }

  1. faiquInit.defaultParams(data:{})

default:{credentials: 'include' }

  1. faiquInit.err_catch(param:Function)

This method only applies to the error in the faiqu object and the error in preMethod

First Level

  1. faiqu (url:string)

Initialize a faiqu object as the request url

Second Level

  1. params(data:{})
  2. json ()

set requeset header 'Content-type'=>'application/json'

  1. headers(data:{})

Third Level

  1. get()
  2. post ()
  3. put (id?:string)
  4. delete(id?:string)