Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VueJS GET request with Bearer token

I am experimenting with Kentico Delivery Preview API using VueJS, which allows you to get unpublished content by submitting a bearer token for authorisation (https://developer.kenticocloud.com/reference#authentication). However, no matter what I do I get a 401 in response. PROJECT_ID, ITEM_NAME and TOKEN are all correct, taken from the project, so it's not a typo issue. I admit I don't have much experience with auth, but any help would be appreciated:

var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!'
    },
    mounted () {
        axios
          .request({
            url: '/items/ITEM_NAME',
            method: 'get',
            baseURL: 'https://preview-deliver.kenticocloud.com/PROJECT_ID',
            headers: {
                'Authorisation': 'Bearer TOKEN'
            }
          })
          .then(response => {
            console.log(response.data)
          })
      }

})
like image 681
Chris Wickham Avatar asked Dec 10 '18 12:12

Chris Wickham


1 Answers

As pointed out by Walter in the comments, I spelt Authorization with an S rather than a Z.. because I'm English. Whoops.

like image 112
Chris Wickham Avatar answered Oct 10 '22 15:10

Chris Wickham