0π
β
Let me explain you the flow of the code you posted :
- Once component mounted, The first method which is getting called is
mounted()
. In this method you are fetching theendopint
binded to theaction
attribute in yourform
html element and binding that in a data variable viathis.endpoint
. - Now, you are calling
validateForm()
method on click ofsubmit
button to validate the input fields. If validation pass, you are callingsendFormData()
method to make anPOST
API call. - After getting the response, you added a watcher on
status
to update theform.context
value based on the status code you received from an API response. - At the end, you are calling a
checkStatus()
method on success of axios call and in thischeckStatus()
method you are again making an POST API call after every10 seconds
and followingstep 3
.
0π
-
When the components is mounted, you run the form binded action on (submit?)
-
The action is probably binded to the sendFormData function(in methods)
-
Inside sendFormData, there is the setup of the axios request, followed be a then callback which handles the response from the request
-
The checkStatus function is called inside the "then" block
-
Sends the same data back to the server every 10 seconds if the previous response
doesnβt have status code other than 200 or 500. -
ValidateForm is may binded to some onInput or onChange event on the template
** The watcher is always looking for the status code and updates a form context
Source:stackexchange.com