Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form response event in case of not 200 code returns empty object instead of axios response #83

Closed
enduro44 opened this issue Nov 29, 2023 · 1 comment

Comments

@enduro44
Copy link

Environment

Can be reproduced in sandbox
https://codesandbox.io/p/devbox/trusting-cherry-8z79lq

Reproduction

  • Try to submit form
  • See {} in console log output

Describe the bug

Seems that problem is in useVueForm send function if axios.request fails it throws an exception and response is not set in this case

response = await services.value.axios.request({
          url,
          method: method.toLowerCase(),
          [method.toLowerCase() === 'get' ? 'params' : 'data']: data,
        })

so it is empty object in

 finally {
      fire('response', response, form$.value)
      submitting.value = false
    }

Additional context

No response

Logs

No response

@adamberecz
Copy link
Collaborator

Fixed in 1.6.4.

To summerize, these are the three possible cases when submitting a form:

1) response is 2xx

  • @response receives
      - 1st param: the Axios response
      - 2nd param: form instance
  • @success receives
      - 1st param: the Axios response
      - 2nd param: form instance
  • @error is not triggered
     

2) response is outside of 2xx

  • @response receives
      - 1st param: the Axios response
      - 2nd param: form instance
  • @success is not triggered
  • @error receives
      - 1st param: the AxiosError (contains response)
      - 2nd param: form instance

3) some other error occured, no response at all

  • @response is not triggered
  • @success is not triggered
  • @error receives
      - 1st param: the error
      - 2nd param: form instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants