super-inflater
v0.0.6-dms-rc
Published
## Getting started
Downloads
5
Maintainers
Readme
super-inflater
Getting started
$ npm install super-inflater --save
OR$ yarn add super-inflater --save
Mostly automatic installation
$ react-native link 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
➜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.reactlibrary.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 ':super-inflater' project(':super-inflater').projectDir = new File(rootProject.projectDir, '../node_modules/super-inflater/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':super-inflater')
Windows
- In Visual Studio add the
SuperInflater.sln
innode_modules/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 '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)
})