Created
August 22, 2017 16:20
-
-
Save Kelin2025/8edf7a09d97f97789e02d15ab1deb20c to your computer and use it in GitHub Desktop.
Apicase mixins example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Container } from 'apicase' | |
export default new Container({ | |
services: { | |
posts: { | |
url: '/posts', | |
// You can use it for shortcuts | |
// or more interesting computed properties | |
mixins: { | |
success () { | |
return this.ok && this.result.data.length > 0 | |
}, | |
data () { | |
return this.success | |
? this.result.data | |
: null | |
}, | |
firstPostName () { | |
return this.data | |
? this.data[0].name | |
: null | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment