Uploading profile pic with react.js node.js express.js REST API to sqlite DB
handleSubmit = e => {
e.preventDefault();
const formData = new FormData();
formData.append('name', this.state.name);
formData.append('nickname', this.state.nickname);
formData.append('profileImg', this.state.profileImg);
axios
.post(`${process.env.API_URL}/player`, formData, {
headers: {
Accept: 'application/json',
'Content-Type': 'multipart/form-data'
}
})
.then(() => this.props.onCreate())
.catch(err => console.log(err));
};