windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Vue.js-resource: http request with api key (Asana)

Asked By: Anonymous

I’m trying to extract some projects from the Asana api with vue-resource (, a Vue.js add-on that makes ajax calls simple. I’m using an api key to access Asana, but I can’t figure out how to pass the key in the request header using vue-resource.

In jQuery this works, using beforeSend:

 $.ajax ({
        type: "GET",
        url: ",notes",
        dataType: 'json',
        beforeSend: function(xhr) { 
            xhr.setRequestHeader("Authorization", "Basic " + "XXXXXX"); 
        success: function (data){
            // console.log(data);

Where XXXXXX is the Asana api key + ‘:’ converted with btoa().

Without needing to authenticate, the Vue instance should be fine with a simple request in the ready function:

new Vue({    
    el: '#asana_projects',    
    data: {
        projects : []
    ready: function() {
        this.$http.get(',notes', function (projects) {
            this.$set('projects', projects); // $set sets a property even if it's not declared
    methods: {
        //  functions here

This, of course, returns a 401 (Unauthorized), since there is no api key in there.

On the vue-resource github page there is also a beforeSend option for the request, but even though it is described right there I can’t seem to figure out the correct syntax for it.

I have tried

    this.$http.get( ... ).beforeSend( ... ); 
    // -> "beforeSend is not a function", and

    this.$http.get(URL, {beforeSend: function (req, opt) { ... }, function(projects) { //set... });
    // -> runs the function but req and opt are undefined (of course)

I realize I’m being less than clever as I fail to understand a syntax that is right there in the documentation, but any and all help would be much appreciated!

Any takers?


Answered By: Anonymous

Perhaps I’m missing some subtlety but can’t you use the options parameter to the $get call to specify the header? From the docs:


Vue.http.get(url, [data], [success], [options])




headers – Object – Headers object to be sent as HTTP request headers


So for instance:

     function (projects) {
        this.$set('projects', projects); // $set sets a property even if it's not declared
         headers: {
            "Authorization": "Basic " + "XXXXXX"

techinplanet staff

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort