Skip to content

dadbob/react-native-pinch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pinch 👌

Callback and promise based HTTP client that supports SSL pinning for React Native.

Installation

Using NPM:

npm install react-native-pinch

Using Yarn:

yarn add react-native-pinch

Pinch API

Example

Examples are using the ES6 standard

Requests can be made by using the fetch(url[, config, [callback]]) method of Pinch.

Using Promises

import pinch from 'react-native-pinch';

pinch.fetch('https://my-api.com/v1/endpoint', {
  method: 'post',
  headers: { customHeader: 'customValue' },
  body: {
    firstName: 'Jake',
    lastName: 'Moxey'
  }, 
  sslPinning: {
    cert: 'my-cool-cert'
  }
})
  .then(res => console.log(`We got your response! Response - ${res}`))
  .catch(err => console.log(`Whoopsy doodle! Error - ${err}`))

Using Callbacks

import pinch from 'react-native-pinch';

pinch.fetch('https://my-api.com/v1/endpoint', {
  method: 'post',
  headers: { customHeader: 'customValue' },
  body: {
    firstName: 'Jake',
    lastName: 'Moxey'
  }, 
  sslPinning: {
    cert: 'my-cool-cert'
  }
}, (err, res) => {
  if (err) {
    console.error(`Whoopsy doodle! Error - ${err}`);
    return null;
  }
  console.log(`We got your response! Response - ${res}`);
})

Response Schema

{
  bodyString: '',
  
  headers: {},
  
  status: 200,
  
  statusText: 'OK'
}

About

SSL pinning for react native

Resources

Stars

Watchers

Forks

Packages

No packages published