@rap-api/vue-swr
v0.0.2
Published
> TODO: description
Downloads
3
Readme
@rap-api/vue-swr
Based on vue swrv
Usage
1. Generate TS code in your project firstly
2. Then install @rap-api/vue-swr
yarn add @rap-api/vue-swr
3. createSwrv
and useSwr
import { defineComponent, ref } from "vue";
import { createSwrv } from '@rap-api/vue-swr';
import { Models, http } from 'src/rapper';
const useSwr = createSwrv<Models>(http);
export default defineComponent({
setup() {
const { data, isValidating, error } = useSwr('POST/user/info', { name: 'swr_name', age: 10 });
const mutate = useMutate();
return (
<>
<h3>React SWR</h3>
<button
loading={isValidating}
onClick={() => mutate('POST/user/info')}
>
Refresh
</button>
{data && <pre>{JSON.stringify(data?.data || [], null, 2)}</pre>}
{error && `Error...`}
</>
}
});
More details, Pls refer HERE