Andrei Cacio
Web developer @ Evozon Systems
http://andrei-cacio.github.io/ironwing
GET -> /users
GET -> /users/:id
POST -> /users
PUT -> /users/:id
DELETE -> /users/:id
JSON API
Server
Client
GET -> /users
GET -> /users/:id
POST -> /users
PUT -> /users/:id
DELETE -> /users/:id
JSON API
Server
Client
ironwingjs
.get()
.create()
.update()
.delete()
/**
* all API calls will being with /api
*/
ironwing.useAdapter('JSON', ['api']);
/**
* GET Users collection
* GET -> /api/users
*/
ironwing('users').then((users) => {
console.log(users.length);
});
ironwing('users', 1).then((user) => {
console.log('My name is ', user.attr.firstName);
});
// My name is John
// /api/users/1
{
"first_name": "John",
"last_name": "Doe"
}
JSON API
ironwing model representation
ironwing('users', 1).then((user) => {
user.attr.firstName = 'Oliver';
user.update();
});
edit-user.js
let user = ironwing.storage.find('users', 1);
export default function render() {
document
.getElementById('user-firstname')
.text(user.attr.firstName);
}
user-firstname-component.js