@apichef/vue-resource

REST API request builder for Vue.js


Keywords
vue, rest, api
License
MIT
Install
npm install @apichef/vue-resource@0.0.3

Documentation

build

REST API request builder for Vue.js

Install

Via yarn

$ yarn add @apichef/vue-resource

Via npm

$ npm install @apichef/vue-resource

Basic usage

import Vue from "vue"
import { VueResource } from "@apichef/vue-resource"
import axios from "axios"

const request = (config) => {
    return axios.request({
        ...config,
        baseURL: 'http://example.com/api/'
    })
}

const nameResolver = resource => resource.type

Vue.use(VueResource, { request, nameResolver })

// in your component

export default {
    data() {
        return {
            projects: []
        }
    },

    async created() {
        await this.fetchProjects()
        // do something
    },

    methods: {
        async fetchProjects() {
            const response = await this.$resource('projects')
                .with([
                    'languages',
                    'subjects',
                ])
                .all()

            this.projects = response.data
        }
    }
}

Testing

$ npm run test

Security

If you discover any security related issues, please email milroy@outlook.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.