How to make a rest post call from ReactJS code?

前端 未结 9 1955
一生所求
一生所求 2020-12-02 05:28

I am new to ReactJS and UI and I wanted to know how to make a simple REST based POST call from ReactJS code.

If there is any example present it would be really h

9条回答
  •  无人及你
    2020-12-02 06:16

    Another recently popular packages is : axios

    Install : npm install axios --save

    Simple Promise based requests


    axios.post('/user', {
        firstName: 'Fred',
        lastName: 'Flintstone'
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });
    

提交回复
热议问题