0.2.19 • Published 5 years ago

@okvue/vue-fetch v0.2.19

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

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

5 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.13

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago