Skip to content

daydayhappychao/faiqu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

fetch for restful

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published