axios cdn
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
Source: www.npmjs.com
header in axios
axios.post('url', {"body":data}, { headers: { 'Content-Type': 'application/json' } } )
Source: stackoverflow.com
axios post with header
// Send a POST request axios({ method: 'post', url: '/user/12345', data: { firstName: 'Fred', lastName: 'Flintstone' }, headers: {'Authorization': 'Bearer ...'} });
Source: github.com
axios post request
const createPostRequest = async () => { try{ const { data } = await axios.post(url, body_data, { headers: { 'Authorization': `Basic ${token}` }, }) console.log(data) } catch (error) { console.log(error) } } createPostRequest();
axios post
const axios = require('axios'); axios.post('/user', { firstName: 'Fred', lastName: 'Flintstone' }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); });
Source: github.com
how to use axios get
const req = async () => { const response = await axios.get('https://dog.ceo/api/breeds/list/all') console.log(response) } req() // Calling this will make a get request and log the response.
Source: flaviocopes.com