loopback-sdk-react
v0.2.7
Published
Loopback SDK React
Downloads
3
Readme
loopback-sdk-react
Loopback SDK React
Installation
Using npm:
$ npm i -g npm
$ npm i --save loopback-sdk-react
Using yarn:
$ npm i -g yarn
$ yarn add loopback-sdk-react
Config
import {config} from 'loopback-sdk-react';
config.set('baseUrl', 'http://localhost:1102/dev/v1');
config.set('access_token', 'xxx');
config.set('lang', 'vi');
Model
App.js
import {generateServices, PropTypes} from 'loopback-sdk-react';
const Model = new generateServices(
"app",
{
find: {
url: '/',
method: 'GET', //option
data: {
filter: {
limit: 10
} //option
}
},
findOne: {
url: '/',
data: {
filter: {
where: {
name: ''
}
}
}
},
findById: {
url: ':id',
data: {
id: ''
}
},
create: {
url: '/',
data: {
title: PropTypes.String,
description: PropTypes.String,
view: PropTypes.Number,
day: PropTypes.Date,
status: PropTypes.Boolean
}
},
update: {
url: '/',
data: {}
},
deleteById: {
url: ':id',
data: {
id: ''
}
},
count: {
url: '/count',
data: {
filter: {
limit: 10
}
}
},
}
);
module.exports = Model;
Services
import App from '../model/App';
App.find({
filter: {
limit: 10
}
}).then((responsive) => {
...
}).catch(() => {
...
})
App.create({
title: '',
description: '',
view: '',
day: '',
status: ''
})