0.2.19 • Published 7 years ago
@okvue/vue-fetch v0.2.19
vue-fetch
simple data fetch for vue(x)
use with vuex
how to use
import vuefetch from "@okvue/vue-fetch"
Vue.use(vuefetch)
// config for fetch client
new Vue({
    fetch: {
        backend: 'https://path/to/api',
        api: {
            repos: 'repos',
            projs: 'projects'
        }
    }
    ...
})
// in vue component
export default {
    created() {
        this.$fetch('repos').then(data => {
            // todo with data
        });
    }
};feature
fetch options
new Vue({
    fetch: {
        method: 'post',
        headers: {
            "content-type": "javascript/json"
        }
        ...
    }
    ...
})or
export default {
    created() {
        this.$fetch('repos', {
            method: 'post',
            headers: {
                "content-type": "javascript/json"
            }
            ...
        }).then(data => {
            // todo with data
        });
    }
};multiple fetch
export default {
    created() {
        this.$fetch(['repos', 'projs']).then(data => {
            // todo with data
        });
    }
};fetch status
export default {
    created() {
        this.$fetch('repos').then(data => {
            // todo with data
        });
    }
    // you can use computed or just use {{this.$store.getters.repos}}
    computed: {
        reposStatus(){
            return this.$store.getters.repos
        }
    }
};query
export default {
    created() {
        this.$fetch({
            url: 'repos',
            query: {
                author: 'owcc'
                ...
            }
        }).then(data => {
            // todo with data
        });
    }
};post data
not allow to multiple post for now
export default { created() { this.$fetch('repos', { name: 'name', other: 'other' }).then(data => { // todo with data }); } };
0.2.19
7 years ago
0.2.18
7 years ago
0.2.17
7 years ago
0.2.16
7 years ago
0.2.15
7 years ago
0.2.14
7 years ago
0.2.13
7 years ago
0.2.12
7 years ago
0.2.11
7 years ago
0.2.10
7 years ago
0.2.9
7 years ago
0.2.8
7 years ago
0.2.7
7 years ago
0.2.6
7 years ago
0.2.5
7 years ago
0.2.4
7 years ago
0.2.3
7 years ago
0.2.2
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.7
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago