1.0.1 • Published 6 years ago
@levlexx/api v1.0.1
api-sdk
Universal API SDK for creating a dynamic url. Vuejs support added via plugin.
!!! Used axios as default client. Not supports another libraries yet!.
Yarn
$ yarn add @levlexx/api
NPM
$ npm install @levlexx/api --save
Usage
Step 1: Preparing the plugin
In order to use this plugin, you first need to pass it to Vue.use
. Your main.js is good place:
main.js:
import Vue from 'vue'
import api from '@levlexx/api/src/vue'
import axios from 'axios'
....
some axios setup
....
Vue.use(api, {client: axios});
Step 2: Usage
You can change behavior by change regexp in options. By default:
awesome-component.vue
this.$api.getSomeTest$url(12); ---> GET some/test/12/url
this.$api.getSomeTest(12); ---> GET some/test/12
this.$api.postSomeUrl(); ---> POST some/url
this.$api.postSomeUrl({test: true}); ---> POST some/url with params test=true
Will call with method GET and url