axios set authorization header

JavaScript
// Send a GET request with the authorization header set to
// the string 'my secret token'
const res = await axios.get('https://httpbin.org/get', {
  headers: {
    'Authorization': 'my secret token'
  }
});const username = ''
const password = ''

const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64')

const url = 'https://...'

axios.post(url, {
  headers: {
    'Authorization': `Basic ${token}`
  }
})
const username = ''
const password = ''

const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64')

const url = 'https://...'
const data = {
  ...
}

axios.post(url, data, {
  headers: {
    'Authorization': `Basic ${token}`
  },
})
Source

Also in JavaScript: