Callback and promise based HTTP client that supports SSL pinning for React Native.
Using NPM:
npm install react-native-pinch
Using Yarn:
yarn add react-native-pinch
Examples are using the ES6 standard
Requests can be made by using the fetch(url[, config, [callback]])
method of Pinch.
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}`))
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}`);
})
{
bodyString: '',
headers: {},
status: 200,
statusText: 'OK'
}