Answers for "nodejs axios"

10

axios cdn

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
Posted by: Guest on July-16-2020
14

axios js and react

import React from 'react';

import axios from 'axios';

export default class PersonList extends React.Component {
  state = {
    persons: []
  }

  componentDidMount() {
    axios.get(`https://jsonplaceholder.typicode.com/users`)
      .then(res => {
        const persons = res.data;
        this.setState({ persons });
      })
  }

  render() {
    return (
      <ul>
        { this.state.persons.map(person => <li>{person.name}</li>)}
      </ul>
    )
  }
}
Posted by: Guest on April-13-2020
9

axios post with header

// Send a POST request
axios({
  method: 'post',
  url: '/user/12345',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  },
  headers: {'Authorization': 'Bearer ...'}
});
Posted by: Guest on April-13-2020
2

how to install axios in react

$ yarn add axios
Posted by: Guest on June-18-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language