Skip to content

Use Nifty mobile backend 's REST API to correspond to React Native

Notifications You must be signed in to change notification settings

satsuki0221/react-native-ncmb

Repository files navigation

React-native-ncmb

http://mb.cloud.nifty.com/doc/current/rest/common/format.html

Use Nifty mobile backend 's REST API to correspond to React Native

Install

yarn add react-native-ncmb

Setting

set your initialPage

import NCMB from 'react-native-ncmb';

NCMB.set({
  applicationkey: 'abcdefghijklmnopqrstuvwxyz0123456789',
  clientKey: 'abcdefghijklmnopqrstuvwxyz0123456789',
});

Use

NCMB.user.login({
  userName: 'user01',
  password: 'test1234'
}).then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

{
  "objectId":"09Mp23m4bEOInUqT",
  "userName":"user01",
  "mailAddress":null,
  "mailAddressConfirm":null,
  "sessionToken":"ebDH8TtmLoygzjqjaI4EWFfxc",
  "createDate":"2013-08-28T07:46:09.801Z",
  "updateDate":"2013-08-30T05:32:03.868Z"
}

Only after login

NCMB.user.logout()
.then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

// type Promise

NCMB.user.create({
  userName: 'user01',
  password: 'test1234'
})
.then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

{
  "createDate":"2013-08-28T11:27:16.446Z",
  "objectId":"epaKcaYZqsREdSMY",
  "sessionToken":"iXDIelJRY3ULBdms281VTmc5O",
  "userName":"user01",
  "authData":null
}

Only after login

NCMB.user.read()
.then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

{
  "objectId":"epaKcaYZqsREdSMY",
  "userName":"YamadaTarou",
  "authData":null,
  "mailAddress":null,
  "mailAddressConfirm":null,
  "createDate":"2013-08-28T11:27:16.446Z",
  "updateDate":"2013-08-28T12:03:28.926Z",
  "acl":{
    "*":{
      "read":true,
      "write":true
    }
  }
}

Only after login

NCMB.user.update({
  mailAddress: "new_address@mail"
  etc...
}).then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

{"updateDate":"2013-08-28T12:21:17.087Z"}

Only after login

NCMB.user.delete()
.then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

// type Promise
NCMB.user.requestPasswordReset({
  mailAddress: '[email protected]'
}).then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

{"createDate":"2013-09-04T04:31:43.371Z"}

NCMB.user.requestMailAddressUserEntry({
  mailAddress: '[email protected]'
}).then(response => {
  console.log(response)
}).catch(error => {
  // type Error
});

result

{"createDate":"2013-09-04T04:31:43.371Z"}

About

Use Nifty mobile backend 's REST API to correspond to React Native

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published