📜  使用 react.js node.js express.js REST API 将配置文件图片上传到 sqlite DB - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:58.308000             🧑  作者: Mango

代码示例1
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));
  };