react 使用axios

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 :发送的数据