user0918232
user0918232

Reputation: 109

Axios not showing headers in xhr browser

I added a Authentication header in my axios request but when I show the response header in browser in XHR, I cannot see the header I set. Thats why the api response telling me Please login first. Did i miss something? thanks for answering

What I tried is

    getMerchants(){
      this.$axios.get(`/userCoins/getMerchantLists?limit=10&offset=1`,null,{
        headers: { 
          'Authentication': this.$cookies.get('auth_token'), 
        }
      }).then((res)=>{
        this.merchants = res.data.results
        console.log(this.$cookies.get('auth_token'))
        console.log(res.data)
      }).catch((err)=>{
         this.$toast.global.error_toast()
      })
    },

In the console, What i get is

1000028:a3bb0cb30689cd8bdaee8bf09e1c5e277341526383be8ff7f78e49223144d05baa056d00
{status: "Please login first"}

The first is my cookie and the second is the api response.

Here is my browser request headers enter image description here

Upvotes: 3

Views: 462

Answers (1)

Mobin Samani
Mobin Samani

Reputation: 275

Try using axios like this:

const req = {
   url: '/userCoins/getMerchantLists?limit=10&offset=1',
   method: 'GET',
   headers: { Authorization: this.$cookies.get('auth_token') }
}

return this.$axios(req)

Upvotes: 0

Related Questions