Skip to content

Commit

Permalink
fix(useAxios): use shallowRef for resposne, data, and error (#421)
Browse files Browse the repository at this point in the history
* fix(useAxios): use shallowRef for resposne, data, and error
* fix types

Co-authored-by: Jacob Clevenger <wheat@jacobs-mbp.attlocal.net>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
3 people committed Apr 7, 2021
1 parent 1b8fed1 commit 7b8551f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/integrations/useAxios/index.ts
@@ -1,4 +1,4 @@
import { Ref, ref } from 'vue-demi'
import { Ref, ref, shallowRef } from 'vue-demi'
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse, CancelTokenSource, AxiosInstance } from 'axios'

export interface UseAxiosReturn<T> {
Expand Down Expand Up @@ -42,12 +42,12 @@ export function useAxios<T = any>(url: string, ...args: any[]) {
instance = args[1]
}

const response = ref<any>(null) as Ref<AxiosResponse<T> | undefined>
const data = ref<any>(undefined) as Ref<T | undefined>
const response = shallowRef<AxiosResponse<T>>()
const data = shallowRef<T>()
const finished = ref(false)
const loading = ref(true)
const canceled = ref(false)
const error = ref<AxiosError<T> | undefined>()
const error = shallowRef<AxiosError<T>>()

const cancelToken: CancelTokenSource = axios.CancelToken.source()
const cancel = (message?: string) => {
Expand Down

0 comments on commit 7b8551f

Please sign in to comment.