Last active
October 8, 2019 06:38
-
-
Save CryDeTaan/9ecb29fde6fe51327aac79aa04b5244a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Submit the form. | |
* | |
* @param {string} requestType | |
* @param {string} url | |
*/ | |
submit(requestType, url) { | |
return new Promise((resolve, reject) => { | |
axios[requestType](url, this.data()) | |
.then(response => { | |
this.onSuccess(response.data); | |
resolve(response.data); | |
}) | |
.catch(error => { | |
this.onFail(error.response.data.errors); | |
reject(error.response.data.errors); | |
}); | |
}); | |
} | |
/** | |
* Send a POST request to the given URL. | |
* . | |
* @param {string} url | |
*/ | |
post(url) { | |
return this.submit('post', url); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment