rn-super-inflater
v2.0.2
Published
## Getting started
Downloads
128
Maintainers
Readme
rn-super-inflater
Getting started
$ npm install rn-super-inflater --save
OR$ 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-inflater
and addSuperInflater.xcodeproj
- In XCode, in the project navigator, select your project. Add
libSuperInflater.a
to 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.sln
innode_modules/rn-super-inflater/windows/SuperInflater.sln
folder to their solution, reference from their app. - Open up your
MainPage.cs
app
- Add
using Inflate.SuperInflater;
to the usings at the top of the file - Add
new SuperInflaterPackage()
to theList<IReactPackage>
returned by thePackages
method
Usage
Import
import SuperInflater from 'rn-super-inflater';
Headers, Params & Body
- Use
set, query, send
function to set a header, param, body or useset, query, send
many time to set multiple headers, params, body.
SuperInflater.
set('Content-Type', 'application/json').
set('Authorization', 'Bearer ****').
query('mobile', '0985****').
query('email', '[email protected]')
- Use
timeout
to set timeout for the request
SuperInflater.
.timeout({
response: 30000,
deadline: 60000
})
set('Content-Type', 'application/json').
set('Authorization', 'Bearer ****').
query('mobile', '0985****').
query('email', '[email protected]')
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
inflate
request, requiredplatform
because ofAndroid
is specialFor
get
request 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
post
request usingsubmitInflate
- with
fix
for 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
send
forobject
body - with
fix
for json body
const body = {
username: "${username}",
password: "${password}"
}
SuperInflater.
platform(Platform.OS).
set('Content-Type', 'application/json').
send(body).
send('new-password', '[email protected]').
putInflate(url).then(res => {
return res
}).catch(err => {
console.log('err', err)
})