Documentation
Here is all public documentation about kinka.
If you didn’t find the answer on your question don’t be shy to post your question here
Kinka have two versions: development and production (~4KB)
For using production version needs set environment variable NODE_ENV
to production
process.env.NODE_ENV = 'production'
Kinka instance
kinka['name'](options) | |||
Name | Options | Returns | Description |
abort |
cancelToken: string
|
undefined |
abort request by abortable key example: kinka.get('/users', { cancelToken: 'usersKey' }) kinka.abort('usersKey') //GET:/users request will been canceled |
all |
requests: Array<Promise>
|
Promise<Response[]> |
That method can helps if needed to wait more than one request Return a promise that is fulfilled when all the items in the array are fulfilled. example: const [friends, family, donuts] = await kinka.all([ kinka.get('/friends'), kinka.get('/family'), kinka.get('/donuts'), ]) console.log(friends.data) console.log(family.data) console.log(donuts.data) |
create |
object?: config (KinkaInstanceOptions)
|
Kinka |
create new kinka instance with your own options. example: const api = kinka.create({baseURL: 'myapi.com'}) api.get('/all') // GET: myapi.com/all promise |
custom |
method: string ,
path: string ,
options?: RequestOptions
|
Promise<Response> |
create request with custom method name.
example: const promise = kinka.custom('kill', '/all') // KILL: myapi.com/all promise |
delete |
path: string ,
options?: RequestOptions
|
Promise<Response> |
create request with DELETE method.
|
get |
path: string ,
options?: RequestOptions
|
Promise<Response> |
create request with GET method.
|
head |
path: string ,
options?: RequestOptions
|
Promise<Response> |
create request with HEAD method.
|
options |
path: string ,
options?: RequestOptions
|
Promise<Response> |
create request with OPTIONS method.
|
patch |
path: string ,
data?: any ,
options?: RequestOptions
|
Promise<Response> |
create request with PATCH method.
|
post |
path: string ,
data?: any ,
options?: RequestOptions
|
Promise<Response> |
create request with POST method.
|
put |
path: string ,
data?: any ,
options?: RequestOptions
|
Promise<Response>
|
create request with PUT method.
|
clone | Kinka |
create a new copy of the current kinka instance |
Interfaces
RequestOptions: object | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Property | Default | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
query?: object | undefined |
query params for your http request example:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cancelToken?:string | undefined |
With abortable key your request have ability to cancel last request if request with the same key is start launching | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
omitCatches?: bool | instance.omitCatches | true |
With true your responses will not be throwing exceptions and you don't need to wrap your requests in try/catch .And if you want to catch exception you can get this from response.err or response.isError Example:
Otherwise:
</td>
</tr>
credentials?: bool |
false
Indicates that this request should use credentials |
(like cookies or specific auth headers) Sets flag withCredentials Read more about it here... successStatus?: number |
range between 200 and 300
Allows to set specific success status for your http request |
If you added this property with 201 value then all another responses with success status codes will be catches an exception, or will have fulfilled `err` property Example:
headers?: object |
{}
Sets request headers |
Example:
data?: any |
undefined
Sets the request body. It is content which needed to send on server
|
timeout?: number |
0
Sets the number of milliseconds after which |
request automatically will be terminated. 0 value means no timeout. Read more about it here... auth?: any |
undefined
Sets data for the instance `auth` mixin. |
Only works if `auth` mixin is setted in instance options Example:
onDownloadProgress?: function |
undefined
Allows to handle progress of the request download |
onUploadProgress?: function |
undefined
Allows to handle progress of the request upload |
|