3.1.0 • Published 9 months ago
rn-super-inflater v3.1.0
rn-super-inflater
Getting started
$ npm install rn-super-inflater --saveOR$ yarn add rn-super-inflater --save
Mostly automatic installation
$ react-native link rn-super-inflater
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries➜Add Files to [your project's name] - Go to
node_modules➜rn-super-inflaterand addSuperInflater.xcodeproj - In XCode, in the project navigator, select your project. Add
libSuperInflater.ato your project'sBuild Phases➜Link Binary With Libraries - Run your project (
Cmd+R)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.inflate.SuperInflaterPackage;to the imports at the top of the file - Add
new SuperInflaterPackage()to the list returned by thegetPackages()method
- Append the following lines to
android/settings.gradle:include ':rn-super-inflater' project(':rn-super-inflater').projectDir = new File(rootProject.projectDir, '../node_modules/rn-super-inflater/android') - Insert the following lines inside the dependencies block in
android/app/build.gradle:compile project(':rn-super-inflater')
Windows
- In Visual Studio add the
SuperInflater.slninnode_modules/rn-super-inflater/windows/SuperInflater.slnfolder to their solution, reference from their app. - Open up your
MainPage.csapp
- Add
using Inflate.SuperInflater;to the usings at the top of the file - Add
new SuperInflaterPackage()to theList<IReactPackage>returned by thePackagesmethod
Usage
Import
import SuperInflater from 'rn-super-inflater';Headers, Params & Body
- Use
set, query, sendfunction to set a header, param, body or useset, query, sendmany time to set multiple headers, params, body.
SuperInflater.
set('Content-Type', 'application/json').
set('Authorization', 'Bearer ****').
query('mobile', '0985****').
query('email', 'john@techfox.io')- Use
timeoutto set timeout for the request
SuperInflater.
.timeout({
response: 30000,
deadline: 60000
})
set('Content-Type', 'application/json').
set('Authorization', 'Bearer ****').
query('mobile', '0985****').
query('email', 'john@techfox.io')Request
- Can use normal request, there are all of
get,post,put,delete. - Inflate request, there are all of
getInflate,submitInflate,putInflate,destroyInflate
- When using normal request:
SuperInflater.
set('Content-Type', 'application/json').
query('lang', 'vi-VN').
get(url).then(res => {
return res.body
}).catch(err => {
console.log('err', err)
})OR with
inflaterequest, requiredplatformbecause ofAndroidis specialFor
getrequest usinggetInflate
SuperInflater.
platform(Platform.OS).
set('Content-Type', 'application/json').
query('lang', 'vi-VN').
getInflate(url).then(res => {
return res
}).catch(err => {
console.log('err', err)
})- For
postrequest usingsubmitInflate - with
fixfor json body
const body = `{
username: "${username}",
password: "${password}"
}`
SuperInflater.
platform(Platform.OS).
set('Content-Type', 'application/json').
fix(body).
submitInflate(url).then(res => {
return res
}).catch(err => {
console.log('err', err)
})- with
sendforobjectbody - with
fixfor json body
const body = {
username: "${username}",
password: "${password}"
}
SuperInflater.
platform(Platform.OS).
set('Content-Type', 'application/json').
send(body).
send('new-password', 'john@techfox.io').
putInflate(url).then(res => {
return res
}).catch(err => {
console.log('err', err)
})