Axios-module: Can't get response headers

Created on 6 Jan 2018  路  3Comments  路  Source: nuxt-community/axios-module

I tried to get headers from response, but i dont know how i can do it
data contains only body

javascript async created () { const data= await this.$axios.$get('posts') this.posts = data }

This question is available on Nuxt.js community (#c67)

Most helpful comment

$get is just a helper, you can use get native

async created() {
  const response = await this.$axios.get('posts')
  this.posts = response.data
}

All 3 comments

$get is just a helper, you can use get native

async created() {
  const response = await this.$axios.get('posts')
  this.posts = response.data
}

Thanx!
this.headers = response.headers
it worked,
in my case(cross domain), not all needed headers were in response
but this is server side problem, i fixed it by adding this code on backend
"Access-Control-Expose-Headers" = ['X-Pagination-Current-Page','X-Pagination-Total-Count']

@anteriovieira I can't get headers of response in the client-side , I can get headers only on server-side do you have any idea where I can config to display them and on client-side response as well ????

Was this page helpful?
0 / 5 - 0 ratings