Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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));
  };
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Uploading #profile #pic #REST #API #sqlite #DB
ADD COMMENT
Topic
Name
1+3 =