axios get request with authorization header not working code example

Example 1: axios set 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}`
  }
})

Example 2: axios post headers authorization

//Data:name and passWord
//url:https://api-dev.thebar.ke
axios.post("url","Data").then(res => {
console.log(res)
localStroge.setItem("access",accessToken)
localStroge.setItem("refresh",refreshToken)
})
//برای لاگین فقط باید اطلاعتی که از ورودی گرفته میشود در هیدر فرستاده شود اگر اطلاعات فرستاده شده درست باشد شما می توانید به توکن دسترسی داشته باشد
//jaberBatoii

Tags:

Misc Example