O
O
onzabr2017-08-10 12:41:56
JavaScript
onzabr, 2017-08-10 12:41:56

How to send headers in GET request using vue-resouce?

Here is the request itself:

this.$http.get(window.APIHost+'/phonebook/contacts', {}, {
  // Заголовки
  headers: {
    'Authorization': 'Bearer '+this.$store.state.access_token
  }
}).then(response => {
  console.log(response)
  if(response.ok) {
    console.log('Out', response.body)
  } else {
    console.log('Error', response.status)
  }
})

And here are the request headers in the exhaust:
Host: 192.168.0.113:9009
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:8080/
Origin: http://localhost:8080
Connection: keep-alive
Cache-Control: max-age=0

Headers are not sent only on GET, all other methods work fine.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question