Created
October 25, 2018 15:22
-
-
Save brandontreb/6cd75c153af72b742f68dc607f527adf 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
handleSubmit(e) { | |
e.preventDefault(); | |
const token = localStorage.getItem(Constants.key_api_auth_token); | |
if(this.state.name && this.state.cost) { | |
const formData = new FormData(); | |
if(this.state.file) { | |
formData.append('file',this.state.file); | |
} | |
formData.append('name', this.state.name); | |
formData.append('cost', this.state.cost); | |
axios.post(Constants.api_url + '/api/rewardItems?token='+token, | |
formData).then((response) => { | |
this.setState({ | |
name: "", | |
cost: "", | |
file: null | |
}) | |
this.getRewardItems(); | |
}).catch(function (error) { | |
this.setState({error: true}); | |
}); | |
} else { | |
this.setState({ | |
error: true | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment