Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { usePostHttp } from './useHttp'
- import { useToasty } from './useSwal'
- import { computed, ref, watchEffect } from '@vue/composition-api'
- import { requestExtract } from '@/utils/requestStatus'
- export const useCreateUser = async (id: string) => {
- const {
- data,
- error,
- loading
- } = usePostHttp<{ name: string }>('sessions', { id })
- const stop = watchEffect(onValidate => {
- const { response , errorMsg } = requestExtract({ data, error })
- if(!loading.value){
- if (response) {
- console.log(response)
- useToasty({
- title: `Olá ${response}`,
- icon: 'success'
- })
- } else {
- useToasty({
- title: `ONG não encontrada`,
- icon: 'error'
- })
- }
- stop()
- }
- })
- return {
- data,
- loading
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement