faiqu v0.1.2
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
faiquInit.baseUrl(url:string)
If the parameters you passed in the faiqu method are ' http://xxxx ', the method does not take effect
faiquInit.preMethod(Array< Function >)
faiquInit.defaultData(data:{})
key:string=>value:Function
faiquInit.defaultHeader(data:{})
default:{ 'Content-type': 'application/x-www-form-urlencoded' }
faiquInit.defaultParams(data:{})
default:{credentials: 'include' }
faiquInit.err_catch(param:Function)
This method only applies to the error in the faiqu object and the error in preMethod
First Level
- faiqu (url:string)
Initialize a faiqu object as the request url
Second Level
- params(data:{})
json ()
set requeset header 'Content-type'=>'application/json'
headers(data:{})
Third Level
- get()
- post ()
- put (id?:string)
- delete(id?:string)