vue-http-fast
v2.1.10
Published
> simplly http request in vue component
Downloads
49
Maintainers
Readme
vue-http-fast
simplly http request in vue component
How to install
yarn add vue-http-fast
# or
npm i vue-http-fast
import vueHttpFast from 'vue-http-fast';
// in Vue 2
Vue.use(vueHttpFast, { ...options });
// in Vue 3
App.use(vueHttpFast, { ...options });
// Option Example
options = {
async launch(api, method, data, headers) {
return axios({
method: 'get',
url: api,
data,
headers,
});
},
};
How to use
<http api="..." method="get" :params="{ hello: 'world' }" v-slot="{ data }">
<div>{{ data }}</div>
</http>
How to Secondary Request
// Refresh according to the method set on the component
this.$refs.http.refresh(params, headers);
// Send request as method get
this.$refs.http.get(params, headers);
// Send request as method post
this.$refs.http.get(params, headers);
Or it can be written in template like
<http api="..." ref="http">
<div>{{ data }}</div>
<button @click="$refs.http.refresh">refresh</button>
<button @click="$refs.http.get({ respect: false })">get</button>
<button @click="$refs.http.post({ respect: true })">post</button>
</http>
Tip
vue-http-fast
do not have the ability to send requests, you need to configure the request class during registration
Docs
| Name | Type | Default | Description | | ------------------- | ------- | -------------------------------------- | --------------------------------- | | api | String | '' | address for request | | method | String | get | be used when making the request | | params | Object | {} | be sent with the request | | immediate | Boolean | true | set request be sended immediately | | wait | Boolean | true | set rending after response | | http | Promise | none | reset tool of sending requests | | requestInterceptor | Promise | (data, headers) => ({ data, headers }) | interceptor before request | | responseInterceptor | Promise | result => result | interceptor after response |