API Integration with Axios in React

How to use Axios with React Install axios npm install axios –save Inport axios on component import axios from axios; To Get Data from url axios.get(`url`) .then(res => { const persons = res.data; this.setState({ persons }); }) Post Data To url const user = { name: this.state.name }; axios.post(`url`, { user }) .then(res => { … More API Integration with Axios in React

Advertisement