coredump / jdd-api
Installs: 9
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 6
Type:laravel-package
- dev-master
- 0.3.0
- 0.2.0
- 0.1.1
- v0.0.1
- dev-dependabot/npm_and_yarn/json5-1.0.2
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/terser-5.14.2
- dev-dependabot/npm_and_yarn/minimist-1.2.6
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/npm_and_yarn/browserslist-4.16.6
- dev-clean_js
This package is auto-updated.
Last update: 2024-11-07 08:33:36 UTC
README
Project setup
composer require coredump/jdd-api
##Examples
Usage inside vue component
export default {
mixins: [ window.ResourceMixin ],
data() {
return {
// GET /api/data/users
users: this.$api.users.array(), // load list of users in an array
// GET /api/data/users/1
user: this.$api.users[1].row(), // load row of user with id=1
// GET /api/data/users/1/roleObject
userRole: this.$api.users[1].roleObject.row(), // load row of user relationship "roleObject"
// GET /api/data/users/1/roleObject/users
userRoleUsers: this.$api.users[1].roleObject.users.array(), // load array of users of the same role of user 1
// POST /api/data/users/1 {call:{method:'getNotifications'}, parameters: {...}}
notifications: this.$api.users[1].arrayCall('getNotifications', {date: today}), // call method "getNotifications" from user 1 model and load its response into an array
// POST /api/data/users/1 {call:{method:'evaluate'}, parameters: {...}}
evaluation: this.$api.users[1].rowCall('evaluate', {date: today}), // call method "evaluate" from user 1 model and load its response into a row object
};
},
methods: {
evaluate(userId) {
// Call a method "evaluate" from user model with id=1
this.$api.users[userId].call('evaluate', {date: today}).then(response => {
console.log('evaluate response: ', response);
});
},
createUser(data = {attributes:{}}) {
this.$api.users.post(data);
},
updateUser() {
this.$api.users[1].put(this.user);
},
deleteUser() {
this.$api.users[1].delete();
},
},
}