Advertisement
kfurfles

use

Mar 29th, 2020
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { usePostHttp } from './useHttp'
  2. import {  watchEffect } from '@vue/composition-api'
  3.  
  4. export const useCreateUser = async (id: string) => {
  5.     const {
  6.         data,
  7.         error,
  8.         loading
  9.     } = usePostHttp('sessions', { id })
  10.  
  11.  
  12.     const stop = watchEffect(onValidate => {
  13.        
  14.         if(!loading.value){
  15.             const response = data.value
  16.             if (response) {
  17.                 alert('success')
  18.             } else {
  19.                 alert('error')
  20.             }
  21.             stop()
  22.         }
  23.     })
  24.  
  25.     return {
  26.         data,
  27.         loading
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement