Skip to content

Instantly share code, notes, and snippets.

@okovalov
Created January 22, 2020 14:54
Show Gist options
  • Save okovalov/c66625c3365387c8682c6aa52e47cb46 to your computer and use it in GitHub Desktop.
Save okovalov/c66625c3365387c8682c6aa52e47cb46 to your computer and use it in GitHub Desktop.
Learn how to send the authorization header using Axios (from https://flaviocopes.com/axios-send-authorization-header/)
const username = ''
const password = ''
const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64')
const url = 'https://...'
axios.post(url, {
headers: {
'Authorization': `Basic ${token}`
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment