1.配置axios代理  使得axios  可以不写根路径

 

package.json

"proxy":"http://localhost:4000",

2.使用

 //发送请求
      axios.post("/api/user/register",newUser)
      .then(res=>{
             console.log(res.data);
      })
      .catch(err=>{
            this.setState({
              errors:err.response.data
            })
      })
      }

  

/api/user/register:是路径
newUser :发送的数据

 

相关文章:

  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
  • 2021-06-16
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-06-29
相关资源
相似解决方案