1.0.10 • Published 1 year ago

utility-rn-typescript v1.0.10

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
1 year ago

utility-rn-typescript

react native utility modules

Installation

npm install utility-rn-typescript
or
yarn add utility-rn-typescript

Usage

// import {request, createAxiosInstance} from 'utility-rn-typescript';

----------AXIOS INSTANCE------------
// a custom config helps us reuse the provided configuration for all the calls made by that particular instance
// create a new instance of axios with a custom config.
// customConfig is of type AxiosRequestConfig
// let customConfig={
//   baseURL: 'https://some-domain.com/api/',
//   timeout: 1000,
//   headers: {'X-Custom-Header': 'foobar'}
// }
// createAxiosInstance(customConfig);

-------API CALL ----------
// method = 'get' | 'post' | 'put' | 'patch' | 'delete'
// url = string (type of url is string)
// data = any   (type of data is any)
// NOTE: for 'get' and 'delete' method pass data as empty object {}
// config = AxiosRequestConfig (type of config is AxiosRequestConfig) 
// NOTE: if you want to pass custom config for specific api 
// const result = await request(method, url, data, config);
// 1.GET  -> const result = await request('get', 'url', {},
//     {
//       baseURL: 'https://jsonplaceholder.typicode.com/posts',
//       timeout: 1000,
//     } 
//     );
// 1.DELETE  -> const result = await request('delete', 'url', {},
//     {
//       baseURL: 'https://jsonplaceholder.typicode.com/posts',
//       timeout: 1000,
//     } 
//     );
// 1.POST  -> const result = await request('post', 'url', {title:"foo"},
//     {
//       baseURL: 'https://jsonplaceholder.typicode.com/posts',
//       timeout: 1000,
//     } 
//     );
// 1.PUT  -> const result = await request('put', 'url', {title:"foo"},
//     {
//       baseURL: 'https://jsonplaceholder.typicode.com/posts',
//       timeout: 1000,
//     } 
//     );
// 1.PATCH  -> const result = await request('patch', 'url', {title:"foo"},
//     {
//       baseURL: 'https://jsonplaceholder.typicode.com/posts',
//       timeout: 1000,
//     } 
//     );

import {request, createAxiosInstance} from 'utility-rn-typescript';
  createAxiosInstance({
      baseURL: 'https://jsonplaceholder.typicode.com/posts',
      timeout: 1000,
    });

  const result = await request('get', '/1', {});
                                      

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.0.10

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago